Toggle

A button that stays pressed, like Billable on a time entry or Bold in an editor. Built on ui-sdk's Toggle: it says aria-pressed, and Space or Enter flips it. Off is the Outline button; on takes the tinted navy pick.

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

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

Playground

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

Props

children
size
icon
disabled

Best practices

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

GuidancePractice
DoUse it for a button that stays pressed, like Billable on a time entry or Bold in an editor.
DoGive an icon-only toggle an aria-label, like Bold, and keep that name the same pressed or not. aria-pressed says the state.
DoUse sm, the default, in toolbars, and xs or md to match the buttons beside it.
Don'tUse a row of toggles for one choice from several, like Day, Week or Month. Use SegmentedControl, which allows only one.
Don'tUse it for a setting on a settings page. Use SwitchRow, which pairs the switch with its label and a description.

Props

Also takes ui-sdk's Toggle props: pressed, defaultPressed, onPressedChange, value, disabled and focusableWhenDisabled.

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
size"xs" | "sm" | "md""sm"sm (32 px) by default, as in toolbars; xs and md follow the button ladder.
iconReactNode—A leading icon, or the only content of an icon toggle (which then needs `aria-label`).
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

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

<Toggle>Billable</Toggle>

Keyboard

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

KeysWhat they do
EnterSpacePress the focused toggle.