qat

Toggle

Toggle. It is copied into your app’s ui/ by qatjs add toggle: the code is yours to edit.

Example

Emails on

Example.qx10 lines, 1 reactive nameOpen in the playground
import Toggle from './ui/toggle/toggle.qx'

export default function Example() {
  let mails = state(true)
  return (
    <Toggle label="Email me on failures" bind:checked={mails} />
    <Toggle label="Two-factor sign-in" checked disabled />
    <p>Emails {mails ? 'on' : 'off'}</p>
  )
}
mails state

Add it

shell1 line
npx qatjs add toggle

Toggle

As a custom element: <ui-toggle>.

Toggle: props
PropTypeAttribute
checkedbooleanyes
labelQatNodeproperty only
disabledbooleanyes
Toggle: events
EventDetail
on:update:checkedCustomEvent<boolean>

Keys

KeyDoes
Space, Enterswitch