Switch

On/off toggle.

Installation

npx @noarka/cli add switch

Usage

tsx
import { Switch } from "@noarka/ui";
tsx
<label className="flex cursor-pointer items-center gap-2 text-sm">  <Switch defaultChecked /> Airplane mode</label>

Examples

States

On, off, and disabled side by side.

With description

Pair the label with helper text for longer explanations.

Settings list

Stacked toggle rows separated by dividers.

API reference

Switch

PropTypeDefault
checked

Controlled checked state. Use with onCheckedChange.

boolean-
defaultChecked

Initially checked when uncontrolled.

booleanfalse
onCheckedChange

Called when the switch is flipped.

(checked: boolean) => void-
disabled

Ignore user interaction. Renders at half opacity.

booleanfalse
readOnly

Show state without allowing flips.

booleanfalse
required

Require the switch to be on before form submit.

booleanfalse
name

Identifies the field when the form is submitted.

string-
value

Value submitted with the form when on.

string-
render

Polymorphic render prop. Use to render a custom element.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default switch styles.

string-