Core
Glass Provider
Sets the theme and accessibility preferences that every Glassy UI component follows.
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-providerAdds 4 files to components/glassyui.
Usage
import { GlassProvider } from "@/components/glassyui/glass-provider";
export function AppProviders({ children }: { children: React.ReactNode }) {
return <GlassProvider>{children}</GlassProvider>;
}import { GlassButton } from '@/components/glassyui/glass-button';
import { GlassProvider, usePreferences } from '@/components/glassyui/glass-provider';
function ThemeButton() {
const { preferences, setPreferences } = usePreferences();
const next = preferences.theme === 'dark' ? 'light' : 'dark';
return (
<GlassButton onPress={() => setPreferences({ theme: next })}>
{next === 'light' ? 'Use light glass' : 'Use dark glass'}
</GlassButton>
);
}
// Wrap your app once. It follows the device's appearance, Reduce Motion and Reduce
// Transparency settings until you set your own.
export default function ProviderExample() {
return (
<GlassProvider>
<ThemeButton />
</GlassProvider>
);
}
It also uses Glass Button. Install them together:
npx shadcn@4.14.1 add @glassyui-native/glass-provider @glassyui-native/glass-button && npx expo install --fixExamples
<GlassProvider defaultTheme="light">{children}</GlassProvider><GlassProvider>
<LiquidFilters />
{children}
</GlassProvider>API reference
GlassProvider
Holds the preferences and writes them to data-lg-* attributes on the html element.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | None | The app, or the part of it that uses glass components. |
defaultTheme | 'light' | 'dark' | system setting | Theme a visitor sees until they choose one; without it the provider follows prefers-color-scheme. A saved choice always wins. |
usePreferences
Hook that returns { preferences, setPreferences }. Throws outside GlassProvider.
| Prop | Type | Default | Description |
|---|---|---|---|
preferences.theme | 'light' | 'dark' | defaultTheme, else system | Active colour theme. |
preferences.mode | 'clear' | 'tinted' | 'clear' | Glass appearance mode. |
preferences.quality | 'low' | 'medium' | 'high' | detected | Rendering quality: low with reduced transparency or 4 GB of device memory or less, medium on touch or with reduced motion, otherwise high. |
preferences.reduceMotion | boolean | prefers-reduced-motion | Stops glass motion. |
preferences.reduceTransparency | boolean | prefers-reduced-transparency | Makes glass opaque and turns off the lens and refraction. |
preferences.thickness | number | 1 | Glass thickness as a multiple of regular; applied between 0.25 and 2. |
setPreferences | (prefs: Partial<GlassyUiPreferences>) => void | None | Merges and applies the given preferences, and saves them to localStorage under glassy-ui-preferences. |
useOptionalPreferences
Same shape as usePreferences, but safe outside GlassProvider: it then returns the defaults, follows the system reduced-transparency setting, and setPreferences does nothing.
PreferencesProvider
Alias of GlassProvider, kept for compatibility.
Also accepts GlassProvider props.
LiquidFilters
Hidden SVG filter definitions (#lg-liquid-refraction and others) for your own CSS. No Glassy UI component needs it. Import it from liquid-filters.
- Types
GlassyUiPreferencesGlassyUiThemeGlassyUiModeGlassyUiQuality
The React Native props and exports are in the component’s source.