Prodular UI

Inputs

Toggle group

A set of toggles where one or several can be pressed. With spacing 0 and the outline variant it is a segmented control.

npx prodular-ui add toggle-group

Segmented control

variant outline with spacing 0. Keep one item pressed.

Multiple and spaced

Anatomy

<ToggleGroup variant="outline" spacing={0} defaultValue={["board"]}>  <ToggleGroupItem value="list">List</ToggleGroupItem>  <ToggleGroupItem value="board">Board</ToggleGroupItem></ToggleGroup>

Guidance

Use it when

  • Switching views (list, board, calendar) or ranges (7, 30, 90 days) in place.
  • Formatting groups where several can be on.

Avoid

  • More than five options. Use Select.
  • Navigation between pages. Use Tabs or links.

Rules for AI agents

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

  • The value is always an array, even for single selection. Read value[0].
  • For a segmented control use variant="outline" spacing={0} and ignore empty changes so one option stays pressed.
  • Pass multiple when several items can be pressed at once.
  • Give the group an aria-label and icon-only items their own aria-label.

API

ToggleGroup

PropTypeDefaultDescription
value / defaultValuestring[]Pressed items.
onValueChange(value: string[]) => voidCalled when the pressed items change.
multiplebooleanfalseAllows several pressed items.
spacingnumber2Gap on the spacing scale. 0 joins the items.
variant / size"default" | "outline" / "sm" | "default" | "lg"Applied to every item.
orientation"horizontal" | "vertical""horizontal"Direction of the items.