# Gradient

> A gradient drawn on the frame's line, in any colours and at any angle, optionally turning around the frame.

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

## Installation

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

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

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

Files it adds: `components/ui/frame.tsx`, `components/ui/frame-effects.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 { FrameGradient } from "@/components/ui/frame-effects";

<Frame radius={12} line={2} className="p-6">
  <FrameGradient colors={["#ccac7b", "#c1727c"]} angle={90} />
  Your content
</Frame>
```

## Examples

### Coloured by utilities

frame-from-*, frame-via-* and frame-to-* on the frame colour every effect layer inside it.

```tsx
import { Frame } from "@/components/ui/frame";
import { FrameGradient } from "@/components/ui/frame-effects";

export default function GradientUtilities() {
  return (
    <Frame
      radius={10}
      line={2}
      className="w-full max-w-xs p-6 frame-from-teal-300 frame-via-indigo-300 frame-to-violet-400"
    >
      <FrameGradient angle={90} />
      <p className="font-mono text-sm">frame-via-indigo-300</p>
    </Frame>
  );
}
```

### A turning comet

Fade the gradient to transparent and spin it for a light that sweeps the border.

```tsx
import { Frame, FrameBorder, FrameCorners } from "@/components/ui/frame";
import { FrameGradient } from "@/components/ui/frame-effects";

export default function GradientComet() {
  return (
    <Frame
      line={2}
      className="w-full max-w-xs p-6 frame-from-indigo-400 frame-via-indigo-400/0 frame-to-indigo-400/0"
    >
      <FrameBorder className="opacity-40" />
      <FrameGradient spin={3} />
      <FrameCorners mark="square" />
      <p className="font-mono text-sm">spin</p>
    </Frame>
  );
}
```

## API reference

### FrameGradient

```tsx
import { FrameGradient } from "@/components/ui/frame-effects";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `colors` | `string[]` | – | Colour stops, in order. Without them the layer reads the frame-from-*, frame-via-* and frame-to-* utilities. |
| `gradient` | `string` | – | Any CSS image, in place of the gradient built from the colours. |
| `angle` | `number \| string` | `135` | Direction of the gradient. Numbers are degrees. |
| `spin` | `boolean \| number` | `false` | Turn the gradient around the frame. A number is the seconds one turn takes; true is 4. |
| `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.
