# Shape Frame

> A frame whose outline follows a shape: bevelled, notched, scooped or rounded corners, and edges with a bite taken out.

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

## Installation

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

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

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

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

<ShapeFrame
  corners={["tl", "br"]}
  size={16}
  fill="var(--background)"
  className="p-6 drop-shadow-lg"
>
  Content
</ShapeFrame>
```

## Examples

### A different corner each

Pass an object to give every corner its own treatment.

```tsx
import { ShapeFrame } from "@/components/ui/shape-frame";

export default function ShapeMixed() {
  return (
    <ShapeFrame
      corner={{ tl: "round", tr: "bevel", br: "scoop", bl: "notch" }}
      size={14}
      fill="var(--background)"
      className="w-full max-w-xs p-6 drop-shadow-lg"
    >
      <p className="font-mono text-sm">One of each</p>
    </ShapeFrame>
  );
}
```

### With Tailwind variants

The fill and line colour are utilities, so they change on hover like any other.

```tsx
import { ShapeFrame } from "@/components/ui/shape-frame";

export default function ShapeVariants() {
  return (
    <ShapeFrame
      corner="bevel"
      size={16}
      className="w-full max-w-xs p-6 transition-colors frame-bg-sky-500/10 frame-color-sky-500/60 hover:frame-bg-sky-500/25 hover:frame-color-sky-500"
    >
      <p className="font-mono text-sm">hover:frame-color-sky-500</p>
    </ShapeFrame>
  );
}
```

## Good to know

- The border, fill and drop-shadow filter follow the shape in every browser. Where border-shape is supported (Chromium 147 and later) the focus outline, box-shadow and hit area follow it too.
- Curved corners (round and scoop) need the CSS shape() function and fall back to a plain rectangular border without it.
- A shape frame is still a frame, so corner marks, fills and effect layers compose inside it.
- For an outline of your own, build it with polygonPaths and pass it as path. The folder, the speech bubble and the edge frame are made this way.

## API reference

### ShapeFrame

```tsx
import { ShapeFrame } from "@/components/ui/shape-frame";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `corner` | `CornerShape \| Partial<Record<Corner, CornerShape>>` | `"bevel"` | Corner treatment: "square", "round", "bevel", "notch" or "scoop". One for every corner, or an object with one per corner. |
| `corners` | `("tl" \| "tr" \| "br" \| "bl")[]` | `all four` | Limits a single corner treatment to these corners. |
| `size` | `number` | `12` | Size of the corner treatment, in pixels. |
| `line` | `number` | `1` | Line width, in pixels. |
| `punch` | `{ sides?, at?, radius? }` | – | Semicircular bites out of the edges: which sides (left and right by default), where along the edge (the middle), and their radius (8). |
| `fill` | `string` | – | Background painted inside the shape. Any CSS background works. |
| `path` | `ShapePath` | – | A ready-made outline from polygonPaths, in place of the corners and the punch. |

Also accepts every Frame prop except radius, and every div attribute.
