PolyHunter

Toggle

A standalone two-state button — same look as a segmented tab item, without the group. Use it for one-off on/off settings; use ToggleGroup for related sets.

Playground

Live preview

Examples

Controlled with sliding pill

Controlled toggles sharing a motionGroup — the pill slides between them

<Toggle pressed={active === "grid"} onPressedChange={() => setActive("grid")} motionGroup="view">
  Grid
</Toggle>
<Toggle pressed={active === "list"} onPressedChange={() => setActive("list")} motionGroup="view">
  List
</Toggle>

States

Code

import { Toggle } from "@npolyhunter/ui";

// Uncontrolled — Radix tracks the pressed state
<Toggle aria-label="Show favorites only">Favorites</Toggle>
<Toggle defaultPressed>Ended hunts</Toggle>

// Controlled
const [on, setOn] = useState(false)
<Toggle pressed={on} onPressedChange={setOn}>Verified</Toggle>

// Sliding pill across a set of controlled toggles
<Toggle pressed={active === "a"} onPressedChange={() => setActive("a")} motionGroup="view">
  Grid
</Toggle>

Code

<Toggle aria-label="Show favorites only" size="default">
  Favorites
</Toggle>

Used in

Includes use through shared UI components.

AppBack Office