# Crosshair

> Rules that overshoot their corners, with a mark on each one.

- Category: Frames (Structural frames: brackets, rails, marks and hatching.)
- Registry item: `frame` — Crosshair is a recipe: a few layers of `frame` put together, not an item of its own. Install `frame` and copy the code below.
- Live preview with controls: https://fancyborders.vercel.app/docs/components/crosshair

## Installation

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

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

Files it adds: `components/ui/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 { Frame, FrameCorners, FrameRules } from "@/components/ui/frame";

<Frame className="p-6">
  <FrameRules overshoot={10} />
  <FrameCorners mark="plus" size={11} />
  Content
</Frame>
```

## API reference

### FrameRules

```tsx
import { FrameRules } from "@/components/ui/frame";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `sides` | `("top" \| "right" \| "bottom" \| "left")[]` | `all four` | Which sides get a line. |
| `overshoot` | `number \| string \| { x?, y? }` | `0` | How far the lines run past the corners. x extends the horizontal lines, y the vertical ones. |
| `dash` | `number \| string` | `4` | Dash length. Setting dash or gap makes the lines dashed. |
| `gap` | `number \| string` | `4` | Space between dashes. |
| `march` | `boolean \| number` | `false` | Make the dashes travel clockwise. A number is the seconds a dash takes to reach the next one's place; true is 0.6. |
| `offset` | `number \| string` | `0` | Distance from the frame's edge. Positive is outward, negative inward. |
| `color` | `string` | – | Overrides the frame's line colour for this layer. |

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

### FrameCorners

```tsx
import { FrameCorners } from "@/components/ui/frame";
```

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `mark` | `"bracket" \| "square" \| "plus" \| "dot"` | `"bracket"` | Built-in mark. Ignored when children are given. |
| `children` | `ReactNode` | – | A custom mark, drawn for the top-left corner and repeated on the rest. |
| `corners` | `("tl" \| "tr" \| "br" \| "bl")[]` | `all four` | Which corners get a mark. |
| `size` | `number \| string` | `12, 7, 11 or 5` | Width and height of each mark. The default depends on the mark: bracket, square, plus, dot. |
| `thickness` | `number \| string` | – | Line width of the mark, when different from the frame's. |
| `align` | `"inside" \| "center"` | – | inside tucks the mark into the corner, center centres it on the frame's line. Brackets and custom marks default to inside. |
| `rotate` | `boolean` | `true` | Rotate each mark to face its corner. Turn off for upright content. |
| `offset` | `number \| string` | `0` | Distance from the frame's edge. Positive is outward, negative inward. |
| `radius` | `number \| string` | – | Radius of a bracket's corner, when different from the frame's. |
| `color` | `string` | – | Colour of the marks. Defaults to the text colour. |

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