Frame
The primitive everything else is built from: an enclosure plus border, rule, corner-mark and fill layers you compose yourself.
Content
Customize
Installation
npx shadcn@latest add https://fancyborders.vercel.app/r/frame.jsonThe CLI copies the component into your project, adds anything it is built on, and writes its CSS into your global stylesheet. New to the CLI? See Installation.
Examples
Tailwind tokens
Colour, line width and radius are ordinary utilities, so they take variants like hover and dark.
frame-color-sky-500/50
Custom corner marks
Pass children to FrameCorners to draw your own mark. It is drawn for the top-left corner and rotated onto the others.
Diamond marks
Good to know
- Layers are absolutely positioned and never take part in layout, so they can go inside a frame in any order, before or after the content.
- Every layer reads its line width, colour and radius from the frame, so setting them once on the frame restyles all of them.
API reference
Frame
import { Frame } from "@/components/ui/frame";| Prop | Type | Default |
|---|---|---|
| radius | number | stringCorner radius shared by the frame and its layers. | 0 |
| line | number | stringLine width shared by borders, rules and marks. | 1 |
| color | stringLine colour for borders, rules and fills. | 22% of the text colour |
Also accepts every div attribute, such as className and style.
FrameBorder
import { FrameBorder } from "@/components/ui/frame";| Prop | Type | Default |
|---|---|---|
| variant | "solid" | "dashed" | "dotted" | "double"The CSS border style. | "solid" |
| offset | number | stringDistance from the frame's edge. Positive is outward, negative inward. | 0 |
| radius | number | stringOverrides the frame's radius for this layer. | – |
| color | stringOverrides the frame's line colour for this layer. | – |
Also accepts every div attribute, such as className and style.
FrameRules
import { FrameRules } from "@/components/ui/frame";| Prop | Type | Default |
|---|---|---|
| sides | ("top" | "right" | "bottom" | "left")[]Which sides get a line. | all four |
| overshoot | number | string | { x?, y? }How far the lines run past the corners. x extends the horizontal lines, y the vertical ones. | 0 |
| dash | number | stringDash length. Setting dash or gap makes the lines dashed. | 4 |
| gap | number | stringSpace between dashes. | 4 |
| march | boolean | numberMake the dashes travel clockwise. A number is the seconds a dash takes to reach the next one's place; true is 0.6. | false |
| offset | number | stringDistance from the frame's edge. Positive is outward, negative inward. | 0 |
| color | stringOverrides the frame's line colour for this layer. | – |
Also accepts every div attribute, such as className and style.
FrameCorners
import { FrameCorners } from "@/components/ui/frame";| Prop | Type | Default |
|---|---|---|
| mark | "bracket" | "square" | "plus" | "dot"Built-in mark. Ignored when children are given. | "bracket" |
| children | ReactNodeA custom mark, drawn for the top-left corner and repeated on the rest. | – |
| corners | ("tl" | "tr" | "br" | "bl")[]Which corners get a mark. | all four |
| size | number | stringWidth and height of each mark. The default depends on the mark: bracket, square, plus, dot. | 12, 7, 11 or 5 |
| thickness | number | stringLine 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 | booleanRotate each mark to face its corner. Turn off for upright content. | true |
| offset | number | stringDistance from the frame's edge. Positive is outward, negative inward. | 0 |
| radius | number | stringRadius of a bracket's corner, when different from the frame's. | – |
| color | stringColour of the marks. Defaults to the text colour. | – |
Also accepts every div attribute, such as className and style.
FrameFill
import { FrameFill } from "@/components/ui/frame";| Prop | Type | Default |
|---|---|---|
| pattern | "hatch" | "cross" | "dots" | "grid"The pattern painted behind the content. | "hatch" |
| size | number | stringSpacing between lines or dots. | 6 |
| thickness | number | stringLine width, or dot radius. | 1 |
| angle | stringDirection of the hatch lines. | "135deg" |
| inset | number | stringDistance kept clear from the frame's edge. | 0 |
| color | stringColour of the pattern. Defaults to the line colour. | – |
Also accepts every div attribute, such as className and style.