Switch

Turns a setting on or off at once, with no Save. Built on ui-sdk's Switch: Space and Enter flip it, and it submits with its form. SwitchRow lays out a labelled setting.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Switch, SwitchRow } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Switch

Props

size
disabled

SwitchRow

One email for each task, as it happens.

Props

label
description
size
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it for a setting that takes effect at once with no Save, like email notifications for assigned tasks.
DoUse SwitchRow for a setting on its own line: the label names the switch, the description says what changes, and pressing the label flips it.
DoWrite the label as a statement of what the switch turns on, like Email me when a task is assigned, so on and off read plainly.
DoUse size="sm" in dense rows, like a table of firm settings. Both sizes extend their hit area past the track.
Don'tUse it inside a form that waits for Save, like a new contact form. Use Checkbox, so nothing changes before the lawyer saves.
Don'tUse it to pick between two named options, like Email or Phone. Use RadioGroup or SegmentedControl, which show both names.

Props

Both also take ui-sdk's Switch props: checked, defaultChecked, onCheckedChange, disabled, readOnly, required, name, value and form.

Switch

PropTypeDefaultDescription
size"md" | "sm""md"md (32 × 18) by default; sm (24 × 14) in dense rows.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

SwitchRow

PropTypeDefaultDescription
label *ReactNode—What the switch turns on, as a statement: "Email me when a task is assigned".
descriptionReactNode—A quieter line under the label, saying what changes.

Code

What the playground shows, ready to copy.

Switch

import { Switch } from "@leap-crm/design-system";

<Switch aria-label="Billable" />

SwitchRow

import { SwitchRow } from "@leap-crm/design-system";

<SwitchRow
  label="Email me when a task is assigned"
  description="One email for each task, as it happens."
/>

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
SpaceToggles it.
EnterSubmits the form, and never toggles it.