Controls
Glass Switch
A glass on/off switch in two sizes.
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-switchAdds 10 files to components/glassyui and installs @radix-ui/react-switch and clsx.
Usage
Usage
import { GlassSwitch } from "@/components/glassyui/glass-switch";
export function SwitchDemo() {
return <GlassSwitch aria-label="Notifications" defaultChecked />;
}React Native usage
import { useState } from 'react';
import { Text, View } from 'react-native';
import { useGlassTheme } from '@/components/glassyui/glass-provider';
import { GlassSwitch } from '@/components/glassyui/glass-switch';
export default function SwitchExample() {
const { colors } = useGlassTheme();
const [notifications, setNotifications] = useState(true);
return (
<View style={{ alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between' }}>
<Text style={{ color: colors.foreground, fontSize: 16 }}>Notifications</Text>
<GlassSwitch
accessibilityLabel="Notifications"
checked={notifications}
onCheckedChange={setNotifications}
/>
</View>
);
}
It also uses Glass Provider. Install them together:
npx shadcn@4.14.1 add @glassyui-native/glass-switch @glassyui-native/glass-provider && npx expo install --fixExamples
With a visible label
<label className="flex items-center justify-between gap-4 select-none">
Autosave
<GlassSwitch />
</label>Small
<GlassSwitch aria-label="Mute" size="sm" />API reference
GlassSwitch
A button with role switch and a glass knob.
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'md' | Track size. |
checked / defaultChecked | boolean | false | Controlled or uncontrolled on state. |
onCheckedChange | (checked: boolean) => void | None | Called with the next checked value. |
disabled | boolean | false | Stops the switch from toggling. |
name / value | string | — / 'on' | Submits the switch with a native form when checked. |
Also accepts Radix Switch.Root props.
- Types
GlassSwitchProps- Accessibility
- Name the switch with aria-label or wrap it in a visible label element.
The React Native props and exports are in the component’s source.