forms
Switch
An on/off toggle for settings that apply the moment they change.
Examples
Settings toggle
Use a switch when the change takes effect immediately, and a checkbox when it is submitted with a form. Each tile copies on its own.
Applies the moment you flip it — no Save button.
Sizes
Three sizes on the same control scale the rest of the library uses. Each tile copies on its own.
Tones
The six semantic tones, each repointing the same `--sw-solid` variable the track fill is built from. Each tile copies on its own.
Disabled
A disabled switch is still a real checkbox input — `:disabled` drives the dimmed track and the cursor together, not just the colour. Each tile copies on its own.
Invalid
Field only marks the switch invalid after a first submit attempt, and `Field.Error` mounts nothing until then.
Controlled
`checked` and `onCheckedChange` are the entire contract — the buttons below prove it by driving every switch from outside.
With text
A label and a line of helper text per switch, wired to the control through `Field.Description` rather than a hand-written `aria-describedby`.
New features and improvements, a few times a month.
Sign-ins from a new device or location.
Offers and other promotional email.
Inline
Compact, `sm`-sized switches sharing one horizontal row, for a quick-settings tray rather than a form.
Settings list
The classic settings-page row — label on the left, switch on the right — built from `Field.Root` with `justify-between` rather than a bespoke layout.
Loading
The switch disables itself while a change is in flight, and only commits once the request resolves — so the UI never shows a state the server rejected. Each tile copies on its own.
Disabled
Syncing…
Settings panel
A grouped, real-world settings screen — two sections of switches sharing one card, each wired the same way as the single examples above.
Notifications
Receipts, invoices, and account activity.
Real-time alerts on this device.
Reserved for security codes.
Privacy
Let others see when you were last online.
Show that a message has been read.
Use activity across apps to tailor ads.
Bold styles
Sixteen looks built entirely from `className`, `containerClassName` and the `--sw-solid`/`--sw-w`/`--sw-h` variables — neon, glass, an oversized track, and more, with no fork of the component underneath any of them. Each tile copies on its own.
Icon toggles
A hidden checkbox behind a fully custom surface — a lock, a play button, a speaker, a power button, a bubble — each swapping icon or clip-path on `peer-checked`/`has-checked` rather than swapping the switch track. Each tile copies on its own.
Menu toggle
The three-bar pattern behind most hamburger menus — the same hidden checkbox driving a track elsewhere in this page now morphs bars into an arrow. Each tile copies on its own.
Day / night
Six takes on the same idea, from a sliding thumb that uncovers the sun or moon to a disc that rises over hills and an orb that just crossfades color and icon. Each tile copies on its own.
Airplane mode
Five takes on the same setting: a plane taxiing into open sky, one pitching into takeoff, one that just cuts the signal bars, a window shade pulling down over the view, and a boarding pass with a plane sliding along its dashed flight path. Each tile copies on its own.
Install progress
Not a toggle at all — a three-phase button (idle, installing, installed) built the same way `loading.tsx` is: real state and a timeout, with the library’s own `Spinner` standing in for the progress ring.
Own the source
Noksha ships as a package and as copy-paste source. Take the files and they are yours to change. These are read from the generated registry, so they are exactly what the library ships — never a paraphrase of it.
Take these files, and field, internal helpers along with them — the imports below point at them. Or let the CLI do it: npx @noksha-ui/cli add switch writes them, follows the same dependency graph, and fixes up the imports.
export { Switch, switchVariants } from './switch.js';
export type { SwitchProps, SwitchSize, SwitchTone } from './switch.types.js';API reference
Accepted values
- SwitchSize
smmdlg
SwitchProps
Also accepts everything from Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'>.
| Prop | Type | Description |
|---|---|---|
| size | SwitchSize | — |
| tone | SwitchTone | — |
| invalid | boolean | — |
| onCheckedChange | (checked: boolean) => void | — |
| containerClassName | string | Classes for the outer wrapper; `className` styles the visible track. |
| thumbClassName | string | Classes for the sliding thumb. |