# Gradient Border

An animated gradient border around any content. The inside stays transparent.

Source: https://gradients.sh/docs/components/gradient-border

<ComponentPreview center>
  <GradientBorderDemo />

  <include cwd lang="tsx" meta='title="gradient-border-demo.tsx"'>components/docs/demos/gradient-border.tsx</include>
</ComponentPreview>

## Installation

```bash
npx shadcn@latest add https://gradients.sh/r/gradient-border.json
```

## Usage

```tsx
import { GradientBorder } from "@/components/gradient-border";

<GradientBorder radius={16}>
  <div className="rounded-[14.5px] bg-background p-5">Your content</div>
</GradientBorder>;
```

The inside stays transparent, so give the content its own background and padding.

For a comparison with a pure CSS conic border, theming and performance notes, see [Animated gradient border in CSS, Tailwind and React](https://gradients.sh/blog/animated-gradient-border-react).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ReactNode` | `—` | The bordered content. Give it its own padding. |
| `kind` | `GradientKind` | `"linear-flow"` | Which gradient fills the component: one of the six free kinds, or any kind registered with the engine. |
| `borderWidth` | `number` | `1.5` | Border thickness in pixels. |
| `radius` | `number` | `16` | Corner radius in pixels. |
| `colors` | `[string, string, ...string[]]` | `["#7c5cff", "#38d6f5", "#ff5ca8", "#ffb36b"]` | Two to six colours: hex, oklch(), names or var(--token). |
| `background` | `string` | `"#7c5cff"` | Base colour under the gradient. |
| `speed` | `number` | `1.2` | 0 to 2. How fast the gradient moves. 0 holds it still. |
| `loopSeconds` | `number` | `18` | 4 to 30. The animation repeats exactly every loopSeconds. |
| `scale` | `number` | `1.2` | 0.25 to 4. Noise frequency: higher means smaller shapes. |
| `warp` | `number` | `0.22` | 0 to 1. Domain-warp strength. |
| `grain` | `number` | `0` | 0 to 1. Film grain. |
| `blur` | `number` | `0.3` | 0 to 1. Softness. |
| `seed` | `number` | `21` | Integer seed for the noise field. |
| `dither` | `{ enabled?: boolean; cell?: number; levels?: number }` | `{ enabled: false, cell: 3, levels: 8 }` | Ordered 4×4 Bayer dither. |
| `interaction` | `{ pointer?: number; scroll?: number }` | `{ pointer: 0, scroll: 0 }` | 0 to 1 influence of the pointer and of scroll velocity. |
| `maxDpr` | `number` | `1.5` | Device pixel ratio cap for the canvas. |
| `reducedMotion` | `"respect" \| "ignore"` | `"respect"` | "respect" shows one still frame when the user prefers reduced motion. |
| `className` | `string` | `—` | Classes for the outer element. Size it here; the gradient fills it. |
