Group-glass toggle
Five decorative frosted-glass single-select toggle groups (FrostToggleGroup, TintToggleGroup, SmokeToggleGroup, CrystalToggleGroup, DepthToggleGroup) built on the ai2 glassDepth scale. Each renders a segmented bar with an opaque, spring-animated active indicator and works controlled or uncontrolled.


Installed with shadcn add · 2 workarounds · theme from registry.json
- applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
- installed base item https://ai2.design/r/tokens.json (registry preview settings)
Installation
Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { FrostToggleGroup } from "@/components/ui/toggle-group-glass"<FrostToggleGroup defaultValue="dim" />- Theme, view or mode switchers (for example Light / Dim / Dark) where a glassy, decorative look fits the page
- Compact segmented controls in a page header, toolbar or settings panel that need a frosted-glass aesthetic
- Choosing between a few mutually exclusive options where a sliding active indicator adds clarity
- Hero or showcase areas where one of the five glass tones (frost, tint, smoke, crystal, depth) should set the mood
Examples
Uncontrolled theme switcher
Default options (Light, Dim, Dark) with the frosted variant. The first option is selected when no defaultValue is given.
import { FrostToggleGroup } from "@/components/ui/toggle-group-glass"export function ThemeSwitch() { return <FrostToggleGroup size="md" defaultValue="light" onValueChange={(v) => console.log(v)} />}Controlled custom options with icons
Custom options with labels and icons, controlled by React state through the tinted variant.
import * as React from "react"import { Bell, Mail } from "lucide-react"import { TintToggleGroup } from "@/components/ui/toggle-group-glass"const options = [ { value: "mail", label: "Mail", icon: <Mail /> }, { value: "alerts", label: "Alerts", icon: <Bell /> },]export function Inbox() { const [value, setValue] = React.useState<string | string[]>("mail") return <TintToggleGroup size="lg" options={options} value={value} onValueChange={setValue} />}Small smoked toolbar control
A compact smoked-glass group in a toolbar, using the sm size.
import { SmokeToggleGroup } from "@/components/ui/toggle-group-glass"const layouts = [ { value: "grid", label: "Grid" }, { value: "list", label: "List" },]export function LayoutToggle() { return <SmokeToggleGroup size="sm" options={layouts} defaultValue="grid" />}Hero layered depth bar
The layered depth variant at the xl size as a showcase element.
import { DepthToggleGroup } from "@/components/ui/toggle-group-glass"export function HeroSwitch() { return <DepthToggleGroup size="xl" defaultValue="dark" />}API reference
Accessibility
- The container has role="group" with an aria-label set per variant (for example "Theme, frosted glass" or "Theme, smoked glass"); pass a meaningful label by choosing the variant, since the label is not a prop.
- Each item is a native button type="button" with aria-pressed reflecting the selected state, so screen readers announce toggle state.
- Keyboard focus is shown with focus-visible:ring-[3px] and ring-ring/50, and disabled items use pointer-events-none with opacity-50.
- Icons are decorative SVGs; provide a text label on every option, or an aria-label on the surrounding element, for icon-only use.
- With reduced motion enabled (useReducedMotion), the indicator moves with a zero-duration transition, so no sliding animation plays.
- The layoutId is unique per instance via React.useId(), so multiple groups on one page do not share indicator animations.
- The group scrolls horizontally inside its viewport on narrow screens with the scrollbar hidden; check that all options stay reachable.
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.
Use the "Group-glass toggle" component (ai2/toggle-group-glass) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/toggle-group-glass2. 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: className, size, type, options, value, defaultValue, onValueChange.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { FrostToggleGroup } from "@/components/ui/toggle-group-glass"<FrostToggleGroup defaultValue="dim" />```Files & dependencies
- registry/ai2/styled/toggle-group-glass.tsx→ components/ui/toggle-group-glass.tsx