# Liquid Metal

> A moving metal ring drawn with WebGL, in chromatic, silver and gold.

- Category: Effects (Gradient, glow and moving light, as more layers for a frame.)
- Registry item: `frame-metal`
- Live preview with controls: https://fancyborders.vercel.app/docs/components/liquid-metal

## Installation

```bash
npx shadcn@latest add https://fancyborders.vercel.app/r/frame-metal.json
```

With the registry namespace: `npx shadcn@latest add @fancyborders/frame-metal`.

The CLI also adds what `frame-metal` is built on: `frame`.

Files it adds: `components/ui/frame.tsx`, `components/ui/frame-metal.tsx`, and its CSS goes into the global stylesheet after the Tailwind import.

## Usage

The code for the preview at its default settings:

```tsx
import { Frame } from "@/components/ui/frame";
import { FrameMetal } from "@/components/ui/frame-metal";

<Frame radius={24} line={2} className="px-7 py-3">
  <FrameMetal preset="silver" />
  Upgrade to Pro
</Frame>
```

## Good to know

- Every metal layer on the page shares one WebGL context and one animation loop, and layers scrolled out of view are skipped.
- The metal is laid over the frame's ordinary line colour and is see-through where it has nothing to add, so the frame keeps a continuous edge. Without WebGL that plain line is all there is.
- This is a client component. The shader is adapted from metal-fx by Jakub Antalik, under the MIT License.

## API reference

### FrameMetal

```tsx
import { FrameMetal } from "@/components/ui/frame-metal";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `preset` | `"chromatic" \| "silver" \| "gold"` | `"chromatic"` | The finish. |
| `theme` | `"dark" \| "light" \| "auto"` | `"auto"` | Which palette to use: the one tuned for dark surfaces or for light ones. auto follows the page's color-scheme (set by most theme switchers), and the system's when the page sets none. |
| `scale` | `number` | `1` | Size of the pattern. 2 doubles it, 0.5 halves it. |
| `speed` | `number` | `1` | Speed of the motion. 0.5 is half speed. |
| `paused` | `boolean` | `false` | Hold the metal still on its current frame. |
| `thickness` | `number \| string` | – | Line width, when different from the frame's. |
| `offset` | `number \| string` | `0` | Distance from the frame's edge. Positive is outward, negative inward. |
| `radius` | `number \| string` | – | Overrides the frame's radius for this layer. |

Also accepts every div attribute, such as className and style.
