# Edge Frame

> A frame with a pattern cut into its edges: zigzag teeth, waves, scallops or the bites of a stamp.

- Category: Shapes (Outlines that are not rectangles, with borders that follow them.)
- Registry item: `edge-frame`
- Live preview with controls: https://fancyborders.vercel.app/docs/components/edge-frame

## Installation

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

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

The CLI also adds what `edge-frame` is built on: `frame`, `shape-frame`.

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

<EdgeFrame
  edge="scallop"
  sides={["top", "bottom", "left", "right"]}
  fill="var(--background)"
  className="p-8 drop-shadow-md"
>
  Content
</EdgeFrame>
```

## Examples

### With effects

A gradient and a glow inside an edge frame take its outline.

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

export default function EdgeEffects() {
  return (
    <EdgeFrame
      edge="scallop"
      sides={["top", "right", "bottom", "left"]}
      size={18}
      line={2}
      fill="var(--card)"
      className="w-full max-w-xs p-8 frame-from-amber-300 frame-to-rose-400"
    >
      <FrameGlow />
      <FrameGradient spin />
      <p className="font-medium">Limited edition</p>
      <p className="mt-1 text-sm text-muted">A gradient on a scalloped edge.</p>
    </EdgeFrame>
  );
}
```

## Good to know

- Each edge fits a whole number of repeats, so the pattern never ends on half a tooth. Doing that needs the frame's size, so this is a client component that measures itself; before it has, and without JavaScript, it is a plain rectangle.
- Zigzags, waves and scallops stand on a line set in from the box by the depth. Give the frame at least that much padding on the patterned edges.
- It is still a shape frame, so effect layers follow the pattern.

## API reference

### EdgeFrame

```tsx
import { EdgeFrame } from "@/components/edge-frame";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `edge` | `"zigzag" \| "wave" \| "scallop" \| "bite"` | `"zigzag"` | The pattern cut into the edges: zigzag teeth, a wave, a scallop of round bumps, or round bites like the edge of a stamp. |
| `sides` | `("top" \| "right" \| "bottom" \| "left")[]` | `top and bottom` | Which edges get the pattern. |
| `size` | `number` | `16` | Length of one tooth, wave or bump, in pixels. Each edge fits a whole number of them, so the real length is the closest that divides it. |
| `depth` | `number` | `8` | How far the pattern reaches in from the edge, in pixels. |

Also accepts line, fill, color and every div attribute.
