Halo Toggle Group Demo

A demo of the HaloToggleGroup component: a single-select segmented control whose selected thumb moves with a spring animation. It shows how to hold the selected value in React state and read it through value and onValueChange.

Halo Toggle Group Demo
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme neutral (none shipped)
  • resolved dependency "halo-toggle-group" from the item's own registry
See how it was built

Installation

pnpm dlx shadcn@latest add @cult-ui/halo-toggle-group-demo

Requires @cult-ui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { useState } from "react"import { HaloToggleGroup } from "@/registry/default/ui/halo-toggle-group"export default function Example() {  const [segment, setSegment] = useState("week")  return (    <HaloToggleGroup      items={[        { label: "Day", value: "day" },        { label: "Week", value: "week" },        { label: "Month", value: "month" },      ]}      onValueChange={setSegment}      value={segment}    />  )}
  • Choosing exactly one option from a small set of mutually exclusive choices, such as a time range (Day / Week / Month).
  • Building a segmented control or view switcher where the active segment should animate smoothly.
  • Adding a playful, spring-animated selector that matches other Halo components such as HaloButton.
  • Showing a live readout of the current selection alongside the control.

Examples

Segmented control (demo)

The registry demo: a controlled single-select with three segments and the selected value displayed below.

segmented-control-(demo).tsx
"use client"import { useState } from "react"import { HaloToggleGroup } from "@/registry/default/ui/halo-toggle-group"export default function HaloToggleGroupDemo() {  const [segment, setSegment] = useState("week")  return (    <div>      <section className="space-y-3">        <h2 className="font-semibold text-foreground text-lg tracking-tight">          Segmented control        </h2>        <HaloToggleGroup          items={[            { label: "Day", value: "day" },            { label: "Week", value: "week" },            { label: "Month", value: "month" },          ]}          onValueChange={setSegment}          value={segment}        />        <p className="text-muted-foreground text-xs tabular-nums">          Selected: {segment}        </p>      </section>    </div>  )}

View switcher

Switching between list and grid views with a controlled value.

view-switcher.tsx
"use client"import { useState } from "react"import { HaloToggleGroup } from "@/registry/default/ui/halo-toggle-group"export default function ViewSwitcher() {  const [view, setView] = useState("list")  return (    <HaloToggleGroup      items={[        { label: "List", value: "list" },        { label: "Grid", value: "grid" },      ]}      onValueChange={setView}      value={view}    />  )}

Filter by status with a readout

A segmented filter whose selection drives a text label.

filter-by-status-with-a-readout.tsx
"use client"import { useState } from "react"import { HaloToggleGroup } from "@/registry/default/ui/halo-toggle-group"export default function StatusFilter() {  const [status, setStatus] = useState("all")  return (    <div className="space-y-2">      <HaloToggleGroup        items={[          { label: "All", value: "all" },          { label: "Open", value: "open" },          { label: "Closed", value: "closed" },        ]}        onValueChange={setStatus}        value={status}      />      <p className="text-muted-foreground text-xs">Showing: {status}</p>    </div>  )}

API reference

PropTypeDefaultDescription
items{ label: string; value: string }[]—The segments to render. Each item has a visible label and a value that is passed to onValueChange. Shape inferred from the demo usage; the full type is defined in the halo-toggle-group source.
valuestring—The currently selected value. Matches one of the items' value fields. Used to make the component controlled, as the demo does with useState.
onValueChange(value: string) => void—Called with the newly selected value when the user picks a segment. The demo passes the state setter directly. Signature inferred from usage; confirm against the halo-toggle-group source.

Accessibility

  • Segments are rendered as interactive toggle controls; keep labels short and descriptive so screen readers announce the option clearly.
  • Use the visible label as the accessible name; avoid relying on the thumb color or motion alone to show the selection, since the demo also prints the selected value as text.
  • Because the animation is spring-driven, consider respecting reduced-motion preferences in your app if the surrounding layout animates heavily.
  • Provide a visible group heading (as the demo does with an h2) so users understand what the segments control.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Halo Toggle Group Demo" component (cult-ui/halo-toggle-group-demo) from its shadcn registry.1. Install it with: npx shadcn@latest add @cult-ui/halo-toggle-group-demo2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: items, value, onValueChange.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { useState } from "react"import { HaloToggleGroup } from "@/registry/default/ui/halo-toggle-group"export default function Example() {  const [segment, setSegment] = useState("week")  return (    <HaloToggleGroup      items={[        { label: "Day", value: "day" },        { label: "Week", value: "week" },        { label: "Month", value: "month" },      ]}      onValueChange={setSegment}      value={segment}    />  )}```

Files & dependencies

  • registry/default/example/halo-toggle-group-demo.tsx
registryDependencieshalo-toggle-group

Looks similar, elsewhere