# Glass

> Liquid Glass: a refracting, blurring surface for toolbars, tab bars and floating controls.

A container made of Liquid Glass: what scrolls behind it shows through blurred,
bent at the rounded edge, under a light veil, with a bright rim. Compose like a
`View`; controls inside keep their own look.

- Category: [Window & layout](https://tarve.dev/docs.md#layout)
- Import: `import { Glass } from "@tarve/core";`
- Props type: `GlassProps`
- Source: [packages/core/src/components/glass.ts:285](https://github.com/omarcosr/tarve/blob/main/packages/core/src/components/glass.ts#L285)

## Usage

```tsx title="Glass.tsx"
import { Glass, Icon, Text, View } from "@tarve/core";

<View style={{ width: 420, height: 200, radius: 18, padding: 24, justify: "end", background: "linear-gradient(135deg, #ff2d55, #af52de 50%, #007aff)" }}>
  <Glass radius={26} style={{ height: 52, padding: { left: 18, right: 18 }, direction: "row", align: "center", gap: 10 }}>
    <Icon name="play" size={18} color="#1c1c1ecc" />
    <Text size={15} weight={600} color="#1c1c1e">Now playing</Text>
  </Glass>
</View>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `appearance` | `"light" \| "dark"` | `"light"` | Light or dark appearance of the rim and veil. Default `light`. |
| `blend` | `number` | — | How far apart in px two merged boxes start bridging; read from the first box of the key. Default 32. |
| `material` | `Partial<GlassMaterial>` | — | Overrides of the material: blur, saturate, refraction, highlight. |
| `merge` | `string` | — | Glass boxes with the same key fuse like drops of liquid: where two come within `blend` px of each other their shapes bridge smoothly, as one surface. The first box of the key in tree order paints the surface: its tint, material and `blend` are the surface's, the others contribute only their shape (up to 8 per key). |
| `radius` | `number` | `26` | Corner radius. Default 26 (a capsule when the box is 52 px tall). |
| `shadow` | `boolean` | `true` | Outer shadow under the glass. Default on. |
| `tint` | `string` | — | Tint colour laid over the variant's veil; the alpha is the strength. `regular` stays frosted under it, `clear` shows it nearly alone. A gradient string passes through as is. |
| `variant` | `GlassVariant` | `"regular"` | `regular`: frosted, legible over anything (toolbars, tab bars). `clear`: barely tinted, for controls over media. `tinted`: `tint` shows through strongly. |

### Inherited from `ViewProps`

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `align` | `Style["align"]` | — |  |
| `autoFocus` | `boolean` | — | Focus this control when it first appears (HTML `autofocus`); interactive views only (Pressable). |
| `children` | `BindableChild` | — |  |
| `dismissOnOutside` | `boolean` | — | A press outside the box fires `onOutsideClick` instead of reaching what is under it (light dismiss). Works on portals and in-flow boxes; an open portal wins. |
| `dragRegion` | `boolean` | — |  |
| `flex` | `number \| string` | — | CSS `flex`: `1` is `1 1 0`; strings take any CSS value, e.g. `"1 1 176px"`. |
| `focusable` | `boolean` | — |  |
| `gap` | `number` | — |  |
| `justify` | `Style["justify"]` | — |  |
| `onOutsideClick` | `() => void` | — | With `dismissOnOutside`: a press (or right click) outside the box. |
| `padding` | `Style["padding"]` | — |  |
| `portal` | `boolean` | — |  |
| `style` | `Reactive<Style>` | — | Values may be signals: setting one restyles this box without a render. |
| `windowAction` | `"minimize" \| "toggleMaximize" \| "toggleFullscreen" \| "close"` | — |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `class`, `className`, `dropTarget`, `fileDropTarget`, `highlight`, `id`, `key`, `motionFrom`, `onDragEnter`, `onDragLeave`, `onDrop`, `onFileDragEnter`, `onFileDragLeave`, `onFileDrop`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`.

## Types

```ts title="BindableChild"
type BindableChild = Child | Signal<unknown> | BindableChild[];
```

```ts title="GlassMaterial"
interface GlassMaterial {
  /** Blur radius in px of what is behind the box (CSS `backdrop-filter: blur()`), 0–64. */
  blur: number;
  /** Colour saturation of the blurred backdrop; 1 leaves it, iOS uses about 1.6. */
  saturate?: number;
  /** How far in px the backdrop bends along the rounded edge (the lens), 0 for none. */
  refraction?: number;
  /** Brightness 0–1 of the rim, the edge reflections and the sheen. */
  highlight?: number;
  /** How much the flat part enlarges the backdrop, as a thick lens does: 0–0.3 (0.06 is iOS-like). */
  magnify?: number;
  /**
   * Boxes painted in one frame with the same key fuse like drops of liquid: their
   * shapes join smoothly where they come within `blend` px of each other.
   */
  merge?: string;
  /** How far apart in px two merged boxes start bridging. Default 0 (touching). */
  blend?: number;
}
```

```ts title="GlassVariant"
type GlassVariant = "regular" | "clear" | "tinted";
```

```ts title="Reactive"
type Reactive<S> = { [K in keyof S]: S[K] | Signal<Exclude<S[K], undefined>> };
```

Previous: [AnimatePresence](https://tarve.dev/docs/components/AnimatePresence.md) · Next: [Text](https://tarve.dev/docs/components/Text.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Glass · Index for agents: https://tarve.dev/llms.txt
