usePlatformAttribute #

Puts the platform detection script into the page head, so CSS can show ⌘ or Ctrl from the first frame: static HTML cannot know the visitor's platform, and swapping the text after hydration makes the layout jump.

Usage #

TypeScript
import { 
usePlatformAttribute
} from 'kawapress/client'
usePlatformAttribute
()

Notes #

Components render both labels and hide one with :root[data-kawa-platform='apple']. Calling this from several components still emits a single tag.

Full type signature
TypeScript
function usePlatformAttribute(): void

Edit this page

Comments