Controls
Glass Segmented Control
A single-choice glass control for two to six options, with a draggable selection.
Preview
Demos ready. Update 0.
The preview runs the React version. On iOS 26 and later, the React Native version uses the system’s own glass. See it on a phone.
Installation
For React 19+ apps with Tailwind CSS 4.
npx shadcn@4.14.1 add @glassyui/glass-segmented-controlAdds 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>
);
}React Native usage
import { useState } from 'react';
import {
GlassSegmentedControl,
GlassSegmentedControlItem,
} from '@/components/glassyui/glass-segmented-control';
export default function SegmentedControlExample() {
const [period, setPeriod] = useState('week');
return (
<GlassSegmentedControl accessibilityLabel="Period" onValueChange={setPeriod} value={period}>
<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.
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue | string | None | The selected option, controlled or uncontrolled. |
onValueChange | (value: string) => void | None | Called with the value of the newly selected option. |
children | ReactNode | None | Two 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.
| Prop | Type | Default | Description |
|---|---|---|---|
valueRequired | string | None | The 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.
The React Native props and exports are in the component’s source.