GitHubGitHub
← All components
Forms / component

Toggle

A compact boolean control with checked motion and disabled state.

OnOffDisabled
Rule enabled
<Toggle label="Enable rule" bind:checked />

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { Toggle } from '@chanrg/4ui';<Toggle label="Enable rule" bind:checked />

API reference

Props

PropTypeDefaultDescription
checkedbooleanfalseBindable state.
onchange(checked) => voidState callback.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.

Accessibility

  • Uses a button with aria-pressed and a mandatory label.

Dependencies

No runtime component dependencies.