Liquid Glass Opacity
Provides a reusable LiquidGlassProvider, useLiquidGlass hook, and Apple System Settings-style Clear ↔ Tinted opacity slider to control Liquid Glass translucency, frost, and contrast globally.
Modeled after Appearance → Liquid Glass in Apple iOS / macOS System Settings, we provide a standalone LiquidGlassProvider, the useLiquidGlass() hook, and a ready-to-use LiquidGlassTintSlider control installable via the shadcn Registry.
- Clear (
tint = 0): Lower backdrop opacity and lighter frost so background colors and details shine through. - Regular (
tint = 0.5): Balanced translucency and text legibility. - Default (
tint = 0.75): Between Regular and Tinted — the initial value on first visit or when used without a Provider, offering stronger contrast for text and controls. - Tinted (
tint = 1): Higher glass opacity and softer frost to boost contrast for content and controls over complex backgrounds.
Interactive Demo: Clear ↔ Tinted
Drag the slider below (or the global Glass Opacity slider in the sidebar footer) to update every Button, Tabs, Select, and glass surface across the site in real time:
Installation (Shadcn Registry)
# Install Provider, Hook, and built-in slider via the @apple-liquid namespace
npx shadcn@latest add @apple-liquid/liquid-glass-provider
# Or install directly via URL
npx shadcn@latest add https://your-domain.com/r/liquid-glass-provider.jsonAll components render normally even without wrapping
<LiquidGlassProvider>via the default CSS token (--liquid-glass-tint: 0.75). Wrapping with the provider unlocks runtime global switching,localStoragepersistence, and built-in multi-language localization vialocale.
Usage in Your Project
1. Wrap your root layout with LiquidGlassProvider
// app/layout.tsx
import { LiquidGlassProvider } from '@/components/ui/liquid-glass-provider';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>
<LiquidGlassProvider defaultTint="regular" locale="en">
{children}
</LiquidGlassProvider>
</body>
</html>
);
}2. Drop in the built-in slider or use useLiquidGlass()
'use client';
import { Button } from '@/components/ui/button';
import {
LiquidGlassTintSlider,
useLiquidGlass,
} from '@/components/ui/liquid-glass-provider';
export function AppearanceSettings() {
const { tint, preset, setPreset, resetTint } = useLiquidGlass();
return (
<div className="space-y-4">
{/* Ready-to-use Apple System Settings-style slider */}
<LiquidGlassTintSlider showDescription />
{/* Or bind custom buttons / presets via the hook */}
<div className="flex flex-wrap items-center gap-2">
<Button size="sm" variant="secondary" onClick={() => setPreset('clear')}>Clear</Button>
<Button size="sm" variant="secondary" onClick={() => setPreset('regular')}>Regular</Button>
<Button size="sm" variant="secondary" onClick={() => setPreset('tinted')}>Tinted</Button>
<Button size="sm" variant="ghost" onClick={resetTint}>
Reset ({Math.round(tint * 100)}% / {preset})
</Button>
</div>
</div>
);
}Local Tint & Accent
Tint and accent follow the same global / local model as the other settings. The outermost <LiquidGlassProvider> is global and writes them onto :root. To give one region its own values (for example, comparing Clear and Tinted side by side), wrap it in <LiquidGlassConfig tint accent>. Overlays opened inside the region (Popover, Select, Dialog, Drawer…) are portaled to <body> but keep the local values:
<LiquidGlassConfig tint="clear">…</LiquidGlassConfig>
<LiquidGlassConfig tint={1} accent="purple">…</LiquidGlassConfig>LiquidGlassConfig values are fixed (you control them). For a local tint the user can change with its own slider, nest a second <LiquidGlassProvider>: a nested provider is automatically local, so syncToRoot={false} is no longer needed.
Global Settings & Per-Component Overrides
<LiquidGlassProvider> sets the defaults every component inherits — locale, messages, glass and disableMotion — and every component can override them with its own props. Highest priority first:
- The component's own prop:
glass,disableMotion,locale,messages. - The nearest enclosing scope: an opaque (
glass={false}) surface or group, an enclosing component'slocale/messages(they also reach its parts and the overlays it opens), or<LiquidGlassConfig>. <LiquidGlassProvider>:glass,disableMotion,locale,messages.- Built-in defaults: glass material (always with edge refraction), animations on, English text. The OS "reduce motion" preference always turns animations off.
| Setting | Global | Per component |
|---|---|---|
locale | <LiquidGlassProvider locale="ja"> | <Select locale="ja"> |
messages | messages={{ select: { title: '…' } }}, keyed by component | <Select messages={{ title: '…' }}> |
glass | <LiquidGlassProvider glass={false}> renders every component opaque | <Button glass> / <Card glass={false}> |
disableMotion | <LiquidGlassProvider disableMotion> turns off the Motion spring animations | <Switch disableMotion={false}> |
tint / accent | Outermost <LiquidGlassProvider> (defaultTint / accent, written to :root) | <LiquidGlassConfig tint accent> for a region, or a nested provider |
<LiquidGlassProvider
locale="zh-CN"
glass={false}
messages={{
select: { title: 'Pick one' },
dataTable: { empty: 'No records' },
}}
>
<Select>…</Select> {/* Pick one · opaque */}
<Select locale="ja">…</Select> {/* Japanese text */}
<Dialog messages={{ close: 'Dismiss' }}>…</Dialog> {/* Only this dialog */}
<Button glass>Glass</Button> {/* Own prop wins: glass */}
</LiquidGlassProvider>Settings passed to a component reach everything it renders: its parts, its children, the components it uses internally and the overlays it opens. <Card glass={false}> makes a Popover opened from it opaque too, and <DataTable locale="ja"> translates its internal Select and buttons too.
Text overrides are deep-merged: built-in text for the language → global messages.<key> → the component's messages, so you only list the labels you change.
Custom Languages
Language tags that are not built in (e.g. vi) render the English text; supply the language through messages. Each component exports its messages type (SelectMessages, DialogMessages, …) for type checking:
import type { DialogMessages } from '@/components/ui/dialog';
import type { SelectMessages } from '@/components/ui/select';
import type { LiquidGlassMessages } from '@/components/ui/liquid-glass-provider';
const vi = {
select: { title: 'Chọn' } satisfies Partial<SelectMessages>,
dialog: { close: 'Đóng', maximize: 'Phóng to', restore: 'Khôi phục' } satisfies DialogMessages,
} satisfies LiquidGlassMessages;
<LiquidGlassProvider locale="vi" messages={vi}>{children}</LiquidGlassProvider>messages belong to the language they were written for: when a component or <LiquidGlassConfig> switches to another locale, the outer messages no longer apply there.
Scoped Settings (LiquidGlassConfig)
To change the settings for one region without a second provider (and without touching tint / accent), wrap it in <LiquidGlassConfig>; unset props inherit from outside:
import { LiquidGlassConfig } from '@/components/ui/liquid-glass-provider';
<LiquidGlassConfig locale="ar" glass={false}>
{/* Arabic (RTL) text, opaque components */}
</LiquidGlassConfig>Message Keys
| Key | Components | Messages type |
|---|---|---|
liquidGlass | LiquidGlassTintSlider / LiquidGlassAccentPicker | LiquidGlassProviderMessages |
breadcrumb | Breadcrumb | BreadcrumbMessages |
carousel | Carousel | CarouselMessages |
codeBlock | CodeBlock | CodeBlockMessages |
colorPicker | ColorPicker | ColorPickerMessages |
combobox | Combobox | ComboboxMessages |
command | Command / CommandDialog | CommandMessages |
contextMenu | ContextMenu | ContextMenuMessages |
dialog | Dialog | DialogMessages |
dropdownMenu | DropdownMenu | DropdownMenuMessages |
iconPicker | IconPicker | IconPickerMessages |
messageScroller | MessageScroller | MessageScrollerMessages |
navigationMenu | NavigationMenu | NavigationMenuMessages |
pagination | Pagination | PaginationMessages |
questionnaire | Questionnaire | QuestionnaireMessages |
select | Select | SelectMessages |
sheet | Sheet | SheetMessages |
sidebar | SidebarProvider | SidebarMessages |
spinner | Spinner | SpinnerMessages |
toast | Toaster | ToastMessages |
tree | Tree / TreeSelect | TreeMessages |
upload | Upload | UploadMessages |
dataTable | DataTable | DataTableMessages |
filePreview | FilePreview / PreviewDialog | FilePreviewMessages |
filterPanel | FilterPanel | FilterPanelMessages |
settingsSplit | SettingsSplit | SettingsSplitMessages |
tiptapEditor | TiptapEditor / TiptapContentRenderer / EditorToolbar | TiptapEditorMessages |
API Reference
LiquidGlassProvider
| Prop | Type | Default | Description |
|---|---|---|---|
defaultTint | number | 'clear' | 'regular' | 'tinted' | 0.75 | Initial opacity (0 Clear, 1 Tinted) |
tint | number | — | Controlled opacity value (0–1) |
onTintChange | (tint: number) => void | — | Callback fired when opacity changes |
locale | LiquidGlassLocaleInput | — | Controlled UI language or BCP 47 tag (en, zh-CN, zh-TW, ja, ko, es, fr, de, pt, ru, it, ar); each component resolves its own built-in translations |
defaultLocale | LiquidGlassLocaleInput | Outer provider's, else 'en' | Initial UI language when uncontrolled |
onLocaleChange | (locale: LiquidGlassLocale, tag: string) => void | — | Callback fired when the locale changes (tag keeps custom languages such as 'vi') |
messages | LiquidGlassMessages | — | Global text overrides keyed by component ({ select: { … }, dataTable: { … } }); a component's own messages wins |
glass | boolean | true | Default material for every component that leaves glass unset; false renders them all opaque. A component's own glass wins |
disableMotion | boolean | false | Turns off the Motion spring animations (press scale, liquid indicators, menu transitions) of every component that leaves disableMotion unset. A component's own disableMotion wins; the OS "reduce motion" preference always applies |
storageKey | string | false | 'apple-liquid-ui:glass-tint' | localStorage persistence key; pass false to disable |
syncToRoot | boolean | true outermost, false nested | Whether tint & accent go to :root (global) or to the provider's subtree and its overlays (local). Detected automatically; rarely needed |
useLiquidGlass()
| Return Field | Type | Description |
|---|---|---|
tint | number | Current opacity value (0–1) |
setTint | (next: number | LiquidGlassPreset) => void | Set opacity continuously or jump to a preset |
preset | 'clear' | 'regular' | 'tinted' | 'custom' | Active preset name |
setPreset | (preset: LiquidGlassPreset) => void | Jump directly to a named preset |
resetTint | () => void | Reset back to defaultTint |
locale | LiquidGlassLocale | Active normalized locale (also readable via useLiquidGlassLocale()) |
localeTag | string | The language tag as given (e.g. 'vi'), also via useLiquidGlassLocaleTag() |
setLocale | (next: LiquidGlassLocaleInput) => void | Switch UI language at runtime |
LiquidGlassTintSlider
| Prop | Type | Default | Description |
|---|---|---|---|
compact | boolean | false | Compact layout for sidebars and toolbars |
showDescription | boolean | false | Show the Apple Settings explanatory description below |
showLabel | boolean | true | Show the header title and current percentage/preset badge |
label | React.ReactNode | 'Liquid Glass Opacity' | Custom header label |
locale | LiquidGlassLocaleInput | — | UI language of this slider; overrides the global locale |
messages | Partial<LiquidGlassProviderMessages> | — | Text overrides; merged over the global messages.liquidGlass |
LiquidGlassConfig
| Prop | Type | Default | Description |
|---|---|---|---|
locale | LiquidGlassLocaleInput | Inherited | UI language of the subtree |
messages | LiquidGlassMessages | Inherited | Text overrides keyed by component, merged over the outer ones |
glass | boolean | Inherited | Default material of the subtree |
disableMotion | boolean | Inherited | Default disableMotion of the subtree |
tint | number | 'clear' | 'regular' | 'tinted' | Inherited | Fixed glass tint of the subtree and its overlays |
accent | LiquidGlassAccent | Inherited | Accent color of the subtree and its overlays |
Hooks for Custom Components
| Hook | Returns | Description |
|---|---|---|
useLiquidGlassLocale() | LiquidGlassLocale | Active built-in locale (component locale → LiquidGlassConfig → provider) |
useLiquidGlassLocaleTag() | string | Active language tag as given, for Intl formatting |
useLiquidGlassTranslation(key, table, { locale, messages }?) | T | Your component's text: table[locale] deep-merged with the global messages[key] and the component's own props |
useInheritedGlass(glass?) | boolean | Resolves a glass prop: own value → enclosing surface → global glass → true (from liquid-surface) |
useLiquidReducedMotion(disableMotion?) | boolean | true when animations should be skipped: own disableMotion → global setting, or the OS "reduce motion" preference |
useLiquidGlassPortalProps() | object | Spread onto a custom portal container (<XxxPrimitive.Portal {...props}>) so overlays keep a local tint / accent |
Quick Start
A Liquid Glass component library built on shadcn/ui, with static documentation and shadcn Registry distribution.
Components
Responsive Liquid Glass component library built on Apple macOS 27 and iOS 27 guidelines, adapting automatically between desktop and mobile with shadcn Registry installation support.