Behive Tech Component Registry

Toggle

v0.5.0Stable

A bare toggle/switch control (built on Radix's `Switch`) — the Radix switch button is this component's own root element. It has no built-in label/hint/error; wrap it in `FormField` for that chrome.

pnpm add @behivetech/atoms.toggle

A bare toggle/switch control (built on Radix's Switch) — the Radix switch button is this component's own root element. It has no built-in label/hint/error; wrap it in FormField for that chrome.

Usage

Open in new tab

Pass invalid (adds the --invalid modifier and sets aria-invalid) to visually mark the toggle as invalid (pair with FormField's error prop for the message).

Properties

Toggle props

PropTypeDefaultDescription
asChildboolean——
classNamestring—Additional class names to merge with the component root element
invalidbooleanfalseMarks the field as invalid: adds the `--invalid` modifier and sets `aria-invalid="true"`

Also accepts the native attributes of its root element (className, aria-*, event handlers, …).