Toggle
A two-state pressed control with semantic surfaces, sizes, and icon layouts.
A two-state pressed control for toolbar actions, filters, and optional settings. Zenos styling follows the design-system Toggle spec: neutral idle/hover surfaces and a red pressed treatment shared with selection tokens.
Backed by Base UI Toggle for upstream behavior and configuration. Zenos owns the public API, styling, and composition shown on this page.
import { Toggle } from "@zentara-co/zenos-ui";Composition
Section titled “Composition”Place label text and icons as children. Padding adjusts automatically for text-only, leading icon, trailing icon, and icon-only layouts (square control at each size). Icons should use aria-hidden when adjacent text supplies the accessible name.
import { PlusIcon } from "@phosphor-icons/react";import { Toggle } from "@zentara-co/zenos-ui"; <Toggle variant="subtle"> <PlusIcon aria-hidden /> Add More</Toggle>;Variants
Section titled “Variants”| Variant | Use |
|---|---|
subtle | Default filled neutral surface (recommended for most toggles). |
subtle-outline | Filled neutral surface with a border; the previous outline appearance. |
outline | Transparent surface; selected border, translucent fill, and semibold label when pressed. |
default | Transparent until hover; lightweight toolbar actions. |
sm, md, and lg map to 28px, 32px, and 40px control heights. Use the same size as neighboring controls to keep a consistent rhythm.
Visual states
Section titled “Visual states”Hover darkens the neutral surface (subtle / subtle-outline) or shows a light neutral fill (default / outline). Pressed outline toggles use border-selected, cover-selected, selected text, and a semibold label in both themes. Other variants retain the accent red subtlest pressed fill. Disabled toggles use muted text and no hover fill; a disabled pressed toggle keeps a faint red surface and muted red label so the prior selection remains visible but not editable.
To preserve the previous filled, bordered appearance, change variant="outline" to variant="subtle-outline".
Custom styling
Section titled “Custom styling”Pass className to replace the surface, border, foreground, shape, or state treatments while retaining Toggle’s sizing, focus ring, disabled behavior, and aria-pressed semantics. Custom classes apply after the selected variant.
Use hover: for pointer feedback and data-[pressed]: for the active state. Prefer semantic color tokens so the result remains legible in light and dark themes. Layout-only classes do not remove the built-in appearance unless they conflict with it.
Controlled state
Section titled “Controlled state”Pair pressed with onPressedChange when application state owns the toggle. Use defaultPressed for an initial uncontrolled state.
Workspace is not pinned.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'outline' | 'subtle' | 'subtle-outline' | subtle | Surface treatment. |
size | 'sm' | 'md' | 'lg' | md | Control height. |
pressed | boolean | — | Controlled pressed state. |
defaultPressed | boolean | false | Initial uncontrolled pressed state. |
onPressedChange | (pressed: boolean, eventDetails) => void | — | Runs when pressed state changes. |
Sizes
smmdlg API
| Prop | Type | Default | Description |
|---|---|---|---|
pressed | boolean | — | Controlled pressed state. |
defaultPressed | boolean | false | Initial uncontrolled state. |
onPressedChange | (pressed: boolean, eventDetails) => void | — | Runs when pressed state changes. |
variant | default | outline | subtle | subtle-outline | subtle | Surface treatment: filled neutral (`subtle`), filled and bordered (`subtle-outline`), transparent with a selected border (`outline`), or transparent until hover (`default`). |
size | sm | md | lg | md | Control size. |
native props | React.Base UI Toggle props | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Toggle uses a native button with aria-pressed. Space or Enter changes its state, and disabled toggles remain unavailable to keyboard and pointer interaction. The label should describe the feature being switched, not its current state; assistive technology announces pressed state separately. Icon-only toggles require aria-label (or visible text elsewhere).
Related
Section titled “Related”Use ToggleGroup when several toggles share selection logic and inherited variant / size.