Prodular UI

Inputs

Toggle

A button that stays pressed, for turning a view option or a format on and off.

npx prodular-ui add toggle

Default and outline

Sizes

Anatomy

<Toggle aria-label="Bold">  <BoldIcon /></Toggle>

Guidance

Use it when

  • Editor formatting (bold, italic) and view options (pin, star) that are either on or off.

Avoid

  • Saved settings. Use Switch.
  • Choosing one of several views. Use ToggleGroup.

Rules for AI agents

Published in llms-full.txt and the registry, so coding agents follow them when they build with this component.

  • Icon-only toggles need aria-label naming the action (Bold), not the state.
  • Use defaultPressed or pressed with onPressedChange. Do not swap the variant to show state.
  • Mark icons with data-icon when there is a text label.
  • Use size="xs" on Toggle for dense toolbars and inspectors instead of overriding its height.

API

Toggle

PropTypeDefaultDescription
variant"default" | "outline""default"Ghost or bordered.
size"xs" | "sm" | "default" | "lg""default"Height. Matches Button.
pressed / defaultPressedbooleanControlled or initial state.
onPressedChange(pressed: boolean) => voidCalled when toggled.