# Glass

Clear liquid glass with SVG refraction and a CSS fallback, and a CSS-only frosted material.

Page: https://sui.draco.dev/docs/components/glass

## Preview

Compare an ordinary and a glass surface in one scene, and switch between Clear glass and frosted glass. The status line reports whether the browser renders SVG refraction or the CSS fallback. Switch the site appearance to compare light and dark themes.

### Example: glass-demo

```tsx
"use client";
import { GlassSurface } from "@workspace/ui/components/glass";
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@workspace/ui/components/tabs";
import { useEffect, useRef, useState } from "react";
import type { ExampleProps } from "../types";

const tiles = [
  "bg-blue-500",
  "bg-emerald-500",
  "bg-amber-400",
  "bg-rose-500",
  "bg-violet-500",
  "bg-cyan-500",
];

type Material = "clear" | "frosted";
type Rendering = "svg" | "css" | "frosted" | "loading";

export default function Example({ locale }: ExampleProps) {
  const chinese = locale === "zh-CN";
  const [material, setMaterial] = useState<Material>("clear");
  const scene = useRef<HTMLDivElement>(null);
  const [rendering, setRendering] = useState<Rendering>("loading");
  const labels = chinese
    ? {
        svg: "当前渲染：SVG 折射 + CSS 材质 + SVG 高光",
        css: "当前渲染：CSS 模糊 + SVG 高光（浏览器不支持 SVG 背景滤镜）",
        frosted: "当前渲染：CSS 模糊（磨砂玻璃无折射与边缘光）",
        loading: "当前渲染：CSS + SVG（等待折射）",
      }
    : {
        svg: "Rendering: SVG refraction + CSS material + SVG highlights",
        css: "Rendering: CSS blur + SVG highlights (no SVG backdrop filters)",
        frosted:
          "Rendering: CSS blur (frosted glass has no refraction or edge light)",
        loading: "Rendering: CSS + SVG (awaiting refraction)",
      };
  const surfaceCopy = chinese
    ? {
        clear: "背景折射、材质着色与柔和的边缘高光",
        frosted: "磨砂背景与材质着色",
      }
    : {
        clear:
          "Background refraction, a material tint and a soft edge highlight.",
        frosted: "A frosted backdrop and a material tint.",
      };
  useEffect(() => {
    const target = scene.current;
    if (!target) return;
    const update = () => {
      const surface = target.querySelector('[data-glass="true"]');
      const state = surface?.getAttribute("data-glass-state");
      if (target.querySelector('[data-frosted="true"]'))
        setRendering("frosted");
      else if (state === "ready") setRendering("svg");
      else if (state === "css" || state === "fallback") setRendering("css");
      else setRendering("loading");
    };
    const observer = new MutationObserver(update);
    observer.observe(target, {
      subtree: true,
      attributes: true,
      attributeFilter: ["data-glass-state", "data-frosted"],
    });
    update();
    return () => observer.disconnect();
  }, []);
  return (
    <Tabs
      value={material}
      onValueChange={(value) => setMaterial(value as Material)}
      className="w-full gap-3"
    >
      <TabsList
        aria-label={chinese ? "玻璃材质" : "Glass material"}
        wrapperClassName="w-full sm:w-fit"
      >
        <TabsTrigger value="clear">{chinese ? "清透" : "Clear"}</TabsTrigger>
        <TabsTrigger value="frosted">
          {chinese ? "磨砂" : "Frosted"}
        </TabsTrigger>
      </TabsList>
      <TabsContent value={material} keepMounted className="grid gap-3">
        <p role="status" className="text-muted-foreground text-sm">
          {labels[rendering]}
        </p>
        <div
          ref={scene}
          className="relative isolate grid min-h-80 w-full items-center gap-4 overflow-hidden rounded-2xl p-6 lg:grid-cols-2"
        >
          <div
            className="absolute inset-0 -z-10 grid grid-cols-3 gap-2 bg-muted p-2"
            aria-hidden="true"
          >
            {tiles.map((tile) => (
              <div key={tile} className={`${tile} rounded-xl`} />
            ))}
          </div>
          <div className="rounded-2xl border bg-background p-6 text-foreground">
            <h3>{chinese ? "普通表面" : "Standard surface"}</h3>
            <p className="mt-2 text-muted-foreground text-sm">
              {chinese
                ? "不透出背景，保持默认外观"
                : "Keeps the default appearance without showing the background."}
            </p>
          </div>
          <GlassSurface
            frosted={material === "frosted"}
            className="rounded-2xl bg-background p-6 text-foreground"
          >
            <h3>{chinese ? "玻璃表面" : "Glass surface"}</h3>
            <p className="mt-2 text-muted-foreground text-sm">
              {surfaceCopy[material]}
            </p>
          </GlassSurface>
        </div>
      </TabsContent>
    </Tabs>
  );
}
```

## Installation

```bash
npx shadcn@latest add @sui/glass
```

With pnpm, Yarn or Bun, use `pnpm dlx`, `yarn dlx` or `bunx --bun` in place of `npx`, and `pnpm add`, `yarn add` or `bun add` in place of `npm install`.

## Usage

```tsx
import { GlassSurface } from "@workspace/ui/components/glass";

<GlassSurface className="rounded-2xl bg-background p-6">
  Glass surface
</GlassSurface>
```

Every glass-capable component takes two props, and describes only itself:

| Prop | Result |
| --- | --- |
| omitted | An ordinary component. |
| `glass` | Clear liquid glass with the defaults. |
| `glass={{ edge, strength, tint, tintOpacity, textGlow }}` | Clear liquid glass with these settings. |
| `frosted` | Frosted glass, drawn by CSS alone. |

Nothing is inherited: a component is glass only when it says so, whatever surrounds it, and settings never pass from a parent to its children. When both are set, `glass` wins. `glass={false}` is the same as omitting it, so `glass={enabled}` works.

```tsx
import { Button } from "@workspace/ui/components/button";
import { GlassSurface } from "@workspace/ui/components/glass";

<GlassSurface glass={{ edge: "vertical" }} />
<GlassSurface frosted />
<Button glass>Action</Button>
```

Pass `render` to keep native semantics, for example `<GlassSurface render={<nav />} />`. `GlassSurface` is Clear unless `frosted` is set. Each glass component is an independent request; observers, listeners and the SVG renderer are shared internally, so no Provider is required.

## Rendering

Clear glass renders native SVG refraction: a geometric displacement map bends the live backdrop along the edges with `feDisplacementMap`, then blurs and saturates it. Nothing is captured, so video, scrolling and animation stay live at the display's frame rate.

The CSS material is its fallback. It applies before a surface is measured, in browsers that cannot paint SVG backdrops (Safari), under `prefers-reduced-transparency`, `prefers-reduced-motion` or forced colors, and if the renderer fails. Fully opaque paint covers the backdrop, so such surfaces keep CSS with the shared edge highlight. Reduced transparency, reduced motion and forced colors show an opaque base with native focus styles.

Frosted glass never runs JavaScript or loads the renderer: it is a stylesheet rule on the component's own element.

### Example: glass-dynamic

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import {
  type GlassConfig,
  GlassSurface,
  refreshGlass,
} from "@workspace/ui/components/glass";
import { Input } from "@workspace/ui/components/input";
import { Label } from "@workspace/ui/components/label";
import { ScrollArea } from "@workspace/ui/components/scroll-area";
import { Slider } from "@workspace/ui/components/slider";
import { useEffect, useId, useRef, useState } from "react";
import type { ExampleProps } from "../types";

const illustration =
  "data:image/svg+xml," +
  encodeURIComponent(
    '<svg xmlns="http://www.w3.org/2000/svg" width="600" height="180" viewBox="0 0 600 180"><defs><pattern id="grid" width="24" height="24" patternUnits="userSpaceOnUse"><path d="M24 0H0V24" fill="none" stroke="#fff" stroke-opacity=".65" stroke-width="1.5"/></pattern></defs><rect width="600" height="180" fill="#648493"/><circle cx="120" cy="80" r="90" fill="#AE916B"/><circle cx="360" cy="140" r="130" fill="#70866A"/><path d="M0 140L600 20" stroke="#BC6C73" stroke-width="24"/><rect width="600" height="180" fill="url(#grid)"/></svg>',
  );
const rows = Array.from({ length: 16 }, (_, index) => index + 1);
export default function Example({ locale }: ExampleProps) {
  const chinese = locale === "zh-CN";
  const stateLabels = chinese
    ? {
        svg: "当前渲染：SVG 折射 + SVG 高光",
        css: "当前渲染：CSS 模糊 + SVG 高光（浏览器不支持 SVG 背景滤镜）",
        loading: "当前渲染：CSS + SVG（等待折射）",
      }
    : {
        svg: "Rendering: SVG refraction + SVG highlights",
        css: "Rendering: CSS blur + SVG highlights (no SVG backdrop filters)",
        loading: "Rendering: CSS + SVG (awaiting refraction)",
      };
  const id = useId();
  const scene = useRef<HTMLDivElement>(null);
  const [rendering, setRendering] = useState<"svg" | "css" | "loading">(
    "loading",
  );
  useEffect(() => {
    const target = scene.current;
    if (!target) return;
    const update = () => {
      const state = target
        .querySelector('[data-glass="true"]')
        ?.getAttribute("data-glass-state");
      if (state === "ready") setRendering("svg");
      else if (state === "css" || state === "fallback") setRendering("css");
      else setRendering("loading");
    };
    const observer = new MutationObserver(update);
    observer.observe(target, {
      subtree: true,
      attributes: true,
      attributeFilter: ["data-glass-state"],
    });
    update();
    return () => observer.disconnect();
  }, []);
  const [text, setText] = useState("SUI / REFRACTION");
  const [strength, setStrength] = useState(22);
  const settings: GlassConfig = { strength };
  const controls = [
    {
      key: "strength",
      label: chinese ? "折射强度" : "Refraction strength",
      value: strength,
      max: 64,
      step: 1,
      change: setStrength,
    },
  ];
  return (
    <div className="grid w-full gap-4">
      <p role="status" className="text-muted-foreground text-sm">
        {stateLabels[rendering]}
      </p>
      <div className="flex flex-wrap items-end gap-3">
        <div className="grid flex-1 gap-2">
          <Label htmlFor={id}>{chinese ? "背景文字" : "Background text"}</Label>
          <Input
            id={id}
            value={text}
            onChange={(event) => setText(event.target.value)}
          />
        </div>
        <Button
          variant="outline"
          type="button"
          onClick={() => refreshGlass(scene)}
        >
          {chinese ? "刷新效果" : "Refresh effect"}
        </Button>
      </div>
      <div className="grid gap-4 sm:grid-cols-2">
        {controls.map(({ key, label, value, max, step, change }) => (
          <div key={key} className="grid gap-2">
            <Label id={`${id}-${key}-label`} htmlFor={`${id}-${key}`}>
              {label}: <output htmlFor={`${id}-${key}`}>{value}</output>
            </Label>
            <Slider
              id={`${id}-${key}`}
              aria-labelledby={`${id}-${key}-label`}
              min={0}
              max={max}
              step={step}
              value={[value]}
              onValueChange={(values) =>
                change(Array.isArray(values) ? values[0] : values)
              }
            />
          </div>
        ))}
      </div>
      <div
        ref={scene}
        className="relative isolate h-96 overflow-hidden rounded-2xl border bg-muted"
      >
        <ScrollArea
          role="region"
          className="absolute inset-0"
          aria-label={chinese ? "可滚动的背景" : "Scrollable background"}
        >
          <img
            src={illustration}
            alt={
              chinese
                ? "由圆形和斜线组成的彩色图案"
                : "Colorful circles and a diagonal stripe"
            }
            className="h-44 w-full object-cover"
          />
          <div className="grid grid-cols-2 gap-2 p-4 sm:grid-cols-4">
            {rows.map((row) => (
              <div
                key={row}
                className="grid min-h-24 content-center gap-1 rounded-xl bg-background p-3"
              >
                <p className="text-primary text-sm">{text}</p>
                <p className="text-muted-foreground text-xs">
                  {chinese ? "网格" : "Grid"} {row}
                </p>
              </div>
            ))}
          </div>
        </ScrollArea>
        <GlassSurface
          glass={settings}
          className="absolute top-20 left-6 w-[calc(50%-2rem)] rounded-2xl bg-background p-4 text-foreground"
        >
          <p>{chinese ? "文字与图片背景" : "Text and image background"}</p>
          <p className="mt-2 text-muted-foreground text-sm">
            {chinese
              ? "调整滑块或滚动背景，比较折射与实际背景"
              : "Adjust the sliders or scroll to compare refraction with the background."}
          </p>
        </GlassSurface>
        <GlassSurface
          glass={settings}
          className="absolute top-20 right-6 w-[calc(50%-2rem)] rounded-2xl bg-background p-4 text-foreground"
        >
          <p>
            {chinese ? "同一场景，独立表面" : "One scene, separate surfaces"}
          </p>
          <p className="mt-2 text-muted-foreground text-sm">
            {chinese
              ? "每个表面各自折射实时背景"
              : "Each surface refracts the live backdrop on its own."}
          </p>
        </GlassSurface>
      </div>
    </div>
  );
}
```

`refreshGlass(target?)` re-measures Clear surfaces inside an element or ref, or all of them when the target is omitted. Call it after changing paint the runtime cannot observe.

## Materials

The two materials follow [Apple's Clear and Regular variants](https://developer.apple.com/design/human-interface-guidelines/materials); the values are Web approximations, not Apple specifications.

| Prop | Tint | Blur | Refraction and edge light | Use |
| --- | --- | --- | --- | --- |
| `glass` | `12%` | `4px` SVG, `6px` CSS fallback | Yes | See-through glass over media; the backdrop stays recognizable. |
| `frosted` | `65%` | `24px` CSS | No | Frosted glass that keeps text legible over busy content. |

Clear refracts with strength `22`; both saturate by `1.3`. The tint comes from the component's own background, so primary and destructive paint keep their color. `glass={{ tintOpacity }}` overrides Clear's tint. Frosted glass reads its tint from the component's surface color; set `--frosted-base`, `--frosted-opacity` or `--frosted-blur` in CSS to restyle it. From bottom to top, a surface composes the blurred or refracted backdrop, the tint, component paint, Clear's edge highlight and content.

### Example: glass-materials

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import { GlassSurface } from "@workspace/ui/components/glass";
import type { ExampleProps } from "../types";

const materials = ["clear", "frosted"] as const;

export default function Example({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  const copy = {
    clear: {
      title: zh ? "清透" : "Clear",
      body: zh
        ? "着色 12%，模糊 4px：背景仍可辨认，适合媒体之上。"
        : "12% tint, 4px blur: the backdrop stays recognizable, for media.",
    },
    frosted: {
      title: zh ? "磨砂" : "Frosted",
      body: zh
        ? "着色 65%，CSS 模糊 24px，无折射：磨砂背景，文字在繁杂内容上依然清晰。"
        : "65% tint, 24px CSS blur, no refraction: frosted, so text stays legible over busy content.",
    },
  };
  return (
    <div className="grid w-full gap-4 overflow-hidden rounded-2xl bg-[url(/playground/backgrounds/coast-poster.jpg)] bg-center bg-cover p-6 sm:grid-cols-2">
      {materials.map((material) => (
        <GlassSurface
          key={material}
          frosted={material === "frosted"}
          className="grid content-start gap-4 rounded-3xl p-5 text-foreground"
        >
          <div className="grid gap-1">
            <p className="font-semibold">{copy[material].title}</p>
            <p className="text-muted-foreground text-sm">
              {copy[material].body}
            </p>
          </div>
          <Button size="sm" className="justify-self-start">
            {zh ? "打开" : "Open"}
          </Button>
        </GlassSurface>
      ))}
    </div>
  );
}
```

## Edge light

`glass={{ edge }}` chooses how light falls on a Clear rim:

- `"diagonal"` (default): a thin rim lit from the top-left and bottom-right corners, fading along the sides.
- `"vertical"`: a lit bevel with reflections along the top and bottom edges.

### Example: glass-edges

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import { type GlassEdge, GlassSurface } from "@workspace/ui/components/glass";
import type { ExampleProps } from "../types";

const edges: GlassEdge[] = ["diagonal", "vertical"];

export default function Example({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  const labels = {
    diagonal: zh ? "对角：左上与右下角照亮" : "Diagonal: lit from the corners",
    vertical: zh ? "上下：上下边缘反光" : "Vertical: lit from top and bottom",
  };
  return (
    // Edge light belongs to Clear. A calm, dark backdrop with soft color
    // makes it easy to compare.
    <div className="grid w-full gap-6 overflow-hidden rounded-2xl bg-[radial-gradient(circle_at_20%_30%,#3b82f680,transparent_45%),radial-gradient(circle_at_80%_70%,#f9731670,transparent_45%),linear-gradient(135deg,#27272a,#18181b)] p-6 sm:grid-cols-2">
      {edges.map((edge) => (
        <div key={edge} className="grid justify-items-center gap-4">
          <p className="font-medium text-sm text-white drop-shadow">
            {labels[edge]}
          </p>
          <div className="flex items-center gap-4">
            <GlassSurface glass={{ edge }} className="size-16 rounded-2xl" />
            <Button glass={{ edge }} variant="outline">
              {zh ? "按钮" : "Button"}
            </Button>
          </div>
          <GlassSurface
            glass={{ edge }}
            className="h-20 w-full max-w-60 rounded-3xl"
          />
        </div>
      ))}
    </div>
  );
}
```

The highlight strength is built in and follows pixel density continuously (`0.15 × device pixel ratio`, from `0.15` to `0.3`), so 1x screens draw a fainter edge. The rim itself is 0.9px wide on every screen.

Edge light belongs to Clear glass, which hides decorative borders and rings. Keyboard focus adds a separate visible outline; forced colors use the system Highlight color. Frosted glass has no edge light. As on iOS, its contrast and shadow outline it, so the component's own border and decorative ring step aside too; it keeps focus rings, and Increase Contrast (`prefers-contrast: more`) brings the border back.

## Popups

Popups choose their material like any other component: put `glass` or `frosted` on the content, such as `PopoverContent`, `SelectContent` or `DialogContent`. Roots like `Popover`, `Select` or `Dialog` take no glass prop. Frosted glass suits menus and dialogs over busy content, as on Apple platforms. Floating layers share one soft, diffuse shadow.

```tsx
<Select>
  <SelectTrigger glass />
  <SelectContent frosted>{/* items */}</SelectContent>
</Select>
```

### Example: glass-popups

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@workspace/ui/components/dropdown-menu";
import { GlassSurface } from "@workspace/ui/components/glass";
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@workspace/ui/components/popover";
import type { ExampleProps } from "../types";

export default function Example({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  return (
    <div className="grid w-full justify-items-center gap-3 overflow-hidden rounded-2xl bg-[url(/playground/backgrounds/coast-poster.jpg)] bg-center bg-cover px-6 py-10">
      <p className="font-medium text-sm text-white drop-shadow">
        {zh
          ? "清透工具栏；每个弹出层自己选择材质，磨砂更易读"
          : "A Clear toolbar; each popup picks its own material, and frosted reads best"}
      </p>
      <GlassSurface className="flex flex-wrap items-center gap-1 rounded-full p-1.5">
        <Popover>
          <PopoverTrigger render={<Button variant="ghost" />}>
            {zh ? "弹出框" : "Popover"}
          </PopoverTrigger>
          <PopoverContent frosted className="w-64 text-sm">
            {zh
              ? "磨砂玻璃让浮层在任何背景上都清晰可读。"
              : "Frosted glass keeps a floating layer legible over any backdrop."}
          </PopoverContent>
        </Popover>
        <DropdownMenu>
          <DropdownMenuTrigger render={<Button variant="ghost" />}>
            {zh ? "菜单" : "Menu"}
          </DropdownMenuTrigger>
          <DropdownMenuContent frosted className="w-44">
            <DropdownMenuItem>{zh ? "重命名" : "Rename"}</DropdownMenuItem>
            <DropdownMenuItem>{zh ? "复制" : "Duplicate"}</DropdownMenuItem>
            <DropdownMenuSeparator />
            <DropdownMenuItem>{zh ? "归档" : "Archive"}</DropdownMenuItem>
          </DropdownMenuContent>
        </DropdownMenu>
        <Popover>
          <PopoverTrigger render={<Button variant="ghost" />}>
            {zh ? "清透" : "Clear"}
          </PopoverTrigger>
          <PopoverContent glass={{ edge: "vertical" }} className="w-64 text-sm">
            {zh
              ? "写 glass 的浮层是清透玻璃，这里用上下边缘光。"
              : "A popup with glass is Clear, here lit from the top and bottom."}
          </PopoverContent>
        </Popover>
      </GlassSurface>
    </div>
  );
}
```

## Controls and content

Glass belongs to navigation, controls and floating layers; content stays ordinary.

- Controls inside a glass surface stay ordinary. Prefer ghost or outline variants on glass, which sit on the material without a solid fill.
- Glass never blurs twice: a glass or frosted component inside another glass layer keeps its tint and edge light but does not blur or refract the backdrop again, because a nested backdrop filter would only frost the outer layer's content. A popup is not inside its trigger's layer, so a glass menu opened from a glass bar is its own full layer.
- A glass `ButtonGroup` is one capsule its buttons sit on; in a group of groups, give each inner group its own `glass`. `Toolbar`, `TabsList`, `PaginationContent` and `Command` work the same way.
- Form fields (`Input`, `Textarea`, `InputGroup`, `SelectTrigger`, `TagInput`) with glass are capsules like iOS search fields, and brighten slightly while focused.
- `Switch` and `Slider` with `glass` turn their thumb into a Clear lens only while dragged. Pressed buttons bloom slightly, and glass buttons also brighten.
- Components that render their glass pieces themselves pass the prop on: `TabBar` (its bar and lens), `NavigationMenu` (its popup), `Toaster` (its toasts), `Image` (its preview controls), `ColorPicker` (its trigger and popup), `PaginationControls` and `PaginationPageSize`.
- Card, QR code, Accordion, Calendar, editors and viewers are content. `Card` and `QRCode` accept `glass` or `frosted`, for example for a widget over media.

### Example: glass-controls

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import { ButtonGroup } from "@workspace/ui/components/button-group";
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@workspace/ui/components/card";
import { GlassSurface } from "@workspace/ui/components/glass";
import { Input } from "@workspace/ui/components/input";
import { Label } from "@workspace/ui/components/label";
import { type ReactNode, useId } from "react";
import type { ExampleProps } from "../types";

function Column({ label, children }: { label: string; children: ReactNode }) {
  return (
    <div className="grid content-start gap-2">
      <p className="font-medium text-white text-xs drop-shadow">{label}</p>
      {children}
    </div>
  );
}

export default function Example({ locale }: ExampleProps) {
  const zh = locale === "zh-CN";
  const id = useId();
  return (
    <div className="grid w-full gap-6 overflow-hidden rounded-2xl bg-[url(/playground/backgrounds/coast-poster.jpg)] bg-center bg-cover p-6 sm:grid-cols-2">
      <Column label={zh ? "各自独立的玻璃按钮" : "Separate glass buttons"}>
        <div className="flex gap-2">
          <Button glass variant="outline">
            {zh ? "归档" : "Archive"}
          </Button>
          <Button glass variant="outline">
            {zh ? "举报" : "Report"}
          </Button>
        </div>
      </Column>
      <Column label={zh ? "ButtonGroup：一个胶囊" : "ButtonGroup: one capsule"}>
        <ButtonGroup glass>
          <Button variant="outline">{zh ? "归档" : "Archive"}</Button>
          <Button variant="outline">{zh ? "举报" : "Report"}</Button>
        </ButtonGroup>
      </Column>
      <Column
        label={
          zh ? "独立的字段：玻璃胶囊" : "A field on its own: a glass capsule"
        }
      >
        <Input glass placeholder={zh ? "搜索" : "Search"} />
      </Column>
      <Column
        label={
          zh
            ? "玻璃面板内的字段：普通字段"
            : "A field inside a glass panel: ordinary"
        }
      >
        <GlassSurface className="grid gap-2 rounded-3xl p-4">
          <Label htmlFor={id}>{zh ? "名称" : "Name"}</Label>
          <Input id={id} defaultValue={zh ? "海岸计划" : "Coastline"} />
        </GlassSurface>
      </Column>
      <Column label={zh ? "Card：普通内容" : "Card: ordinary content"}>
        <Card size="sm">
          <CardHeader>
            <CardTitle>24°</CardTitle>
            <CardDescription>
              {zh ? "上海，多云" : "Shanghai, cloudy"}
            </CardDescription>
          </CardHeader>
        </Card>
      </Column>
      <Column label={zh ? "Card glass：显式开启" : "Card glass: opted in"}>
        <Card size="sm" glass>
          <CardHeader>
            <CardTitle>24°</CardTitle>
            <CardDescription>
              {zh ? "上海，多云" : "Shanghai, cloudy"}
            </CardDescription>
          </CardHeader>
        </Card>
      </Column>
    </div>
  );
}
```

```tsx
import { Card } from "@workspace/ui/components/card";
import { GlassSurface } from "@workspace/ui/components/glass";

<GlassSurface>{/* ordinary content and ghost controls */}</GlassSurface>
<Card glass>{/* a glass widget */}</Card>
```

### Example: glass-composition

```tsx
"use client";
import { Button } from "@workspace/ui/components/button";
import {
  CodeEditor,
  type CodeEditorPlugin,
  codeEditorLabelsZhCN,
} from "@workspace/ui/components/code-editor";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@workspace/ui/components/dialog";
import { Input } from "@workspace/ui/components/input";
import { Label } from "@workspace/ui/components/label";
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@workspace/ui/components/popover";
import {
  CodeViewer,
  codeViewerLabelsZhCN,
} from "@workspace/ui/viewers/code-viewer";
import { useId, useState } from "react";
import type { ExampleProps } from "../types";

const noPlugins: CodeEditorPlugin[] = [];

export default function Example({ locale }: ExampleProps) {
  const chinese = locale === "zh-CN";
  const id = useId();
  const [code, setCode] = useState('const theme = "bamboo";');
  return (
    <div className="relative isolate grid w-full gap-4 overflow-hidden rounded-2xl bg-muted p-5">
      <div
        className="absolute inset-0 -z-10 grid grid-cols-3 gap-3 p-3"
        aria-hidden="true"
      >
        <div className="rounded-2xl bg-emerald-400/70" />
        <div className="rounded-2xl bg-blue-400/70" />
        <div className="rounded-2xl bg-rose-400/70" />
      </div>
      <div className="grid gap-4 rounded-2xl border bg-background p-5">
        <div className="grid gap-2">
          <Label htmlFor={id}>
            {chinese
              ? "原生输入仍可交互"
              : "The native input stays interactive"}
          </Label>
          <Input
            id={id}
            placeholder={chinese ? "输入一些文字" : "Type something"}
          />
        </div>
        <div className="flex flex-wrap gap-2">
          <Popover>
            <PopoverTrigger render={<Button variant="outline" glass />}>
              {chinese ? "玻璃浮层" : "Glass popover"}
            </PopoverTrigger>
            <PopoverContent frosted>
              <p className="text-sm">
                {chinese
                  ? "浮层使用 CSS 磨砂，内容维持清晰"
                  : "The popover frosts with CSS while its content stays clear."}
              </p>
            </PopoverContent>
          </Popover>
          <Dialog>
            <DialogTrigger render={<Button variant="outline" glass />}>
              {chinese ? "打开对话框" : "Open dialog"}
            </DialogTrigger>
            <DialogContent glass>
              <DialogHeader>
                <DialogTitle>
                  {chinese ? "玻璃对话框" : "Glass dialog"}
                </DialogTitle>
                <DialogDescription>
                  {chinese
                    ? "保留焦点管理、键盘和关闭行为"
                    : "Focus management, keyboard access, and dismissal are preserved."}
                </DialogDescription>
              </DialogHeader>
              <Input
                aria-label={chinese ? "对话框输入" : "Dialog input"}
                placeholder={chinese ? "仍可输入" : "Still editable"}
              />
            </DialogContent>
          </Dialog>
        </div>
      </div>
      <CodeEditor
        value={code}
        onChange={setCode}
        language="typescript"
        height={180}
        labels={chinese ? codeEditorLabelsZhCN : undefined}
        plugins={noPlugins}
      />
      <CodeViewer
        code={code}
        language="typescript"
        title={chinese ? "当前代码" : "Current code"}
        maxHeight={160}
        labels={chinese ? codeViewerLabelsZhCN : undefined}
      />
    </div>
  );
}
```

Clear glass keeps its resting edge light and adds a separate outline for keyboard focus, while frosted glass keeps the component's focus ring; ordinary components keep their theme and focus styling. Glass shows the backdrop through, so secondary text moves toward the foreground. Over bright, busy backdrops, `glass={{ textGlow: true }}` adds a tight glow in the material's own tint that hugs text and icons; it is off by default. The glow only shows where the backdrop fights the text, so it stays legible in light and dark mode. Frosted glass's denser tint keeps text legible without a glow. Reduced transparency turns the glow and secondary text change off along with the glass.

## API reference

| Prop | Type | Default / behavior |
| --- | --- | --- |
| Component `glass` | `boolean \| GlassConfig` | Clear liquid glass on this component; `GlassSurface` defaults to `true`. |
| Component `frosted` | `boolean` | Frosted glass on this component; `glass` wins when both are set. |
| Config `edge` | `"diagonal" \| "vertical"` | `"diagonal"`. |
| Config `strength` | `number` | `22`. |
| Config `tint` | `string` | Component background. |
| Config `tintOpacity` | `number` | `0.12`. |
| Config `textGlow` | `boolean` | `false`. |
| `refreshGlass(target?)` | `(target?: GlassTarget) => void` | Re-measure surfaces inside the target, or all when omitted. |
| `GlassSurface` | `useRender` props | Native div props, plus `render` to change the element. |
