Browse docsSegmented Control

Controls

Glass Segmented Control

A single-choice glass control for two to six options, with a draggable selection.

Preview

Demos ready. Update 0.

Installation

For React 19+ apps with Tailwind CSS 4.

npx shadcn@4.14.1 add @glassyui/glass-segmented-control

Adds 13 files to components/glassyui and installs @radix-ui/react-radio-group and clsx.

Usage

Usage

import { GlassSegmentedControl, GlassSegmentedControlItem } from "@/components/glassyui/glass-segmented-control";

export function SegmentedDemo() {
  return (
    <GlassSegmentedControl aria-label="View" defaultValue="week">
      <GlassSegmentedControlItem value="day">Day</GlassSegmentedControlItem>
      <GlassSegmentedControlItem value="week">Week</GlassSegmentedControlItem>
      <GlassSegmentedControlItem value="month">Month</GlassSegmentedControlItem>
    </GlassSegmentedControl>
  );
}

Examples

Controlled

const [view, setView] = useState("list");

<GlassSegmentedControl aria-label="Layout" value={view} onValueChange={setView}>
  <GlassSegmentedControlItem value="list">List</GlassSegmentedControlItem>
  <GlassSegmentedControlItem value="grid">Grid</GlassSegmentedControlItem>
</GlassSegmentedControl>

API reference

GlassSegmentedControl

A Radix RadioGroup root rendered as a glass pill.

PropTypeDefaultDescription
value / defaultValuestringNoneThe selected option, controlled or uncontrolled.
onValueChange(value: string) => voidNoneCalled with the value of the newly selected option.
childrenReactNodeNoneTwo to six GlassSegmentedControlItem elements placed directly inside the control, which CSS counts to place the selection before scripts run.

Also accepts Radix RadioGroup.Root props.

GlassSegmentedControlItem

One option; options share the width equally.

PropTypeDefaultDescription
valueRequiredstringNoneThe value this option selects.

Also accepts Radix RadioGroup.Item props.

Types
GlassSegmentedControlProps
Accessibility
Name the group with aria-label or aria-labelledby; arrow keys move the selection, as in any radio group.