Skip to content
mdxcn is now part of Shadcn Labs. details

frame

Graph

The dashed frame every graph is drawn in. Build with GraphTitle, GraphBody, GraphRule, GraphTrack and GraphTick. Set corner to change the corner character and frame to change the border. Wrap a page in GraphFrameProvider to set the frame for every graph inside it.

use it
Good when you're putting together a custom figure.
instead
If the chart already exists, install that one instead.

box

The default. Dashed border, corner marks, title on the top edge.

[ ROUTES ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank title="ROUTES">

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

install

command

corners

frame="corners" keeps the corner marks and drops the dashed lines.

[ ROUTES ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank title="ROUTES" frame="corners">

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

rule

frame="rule" draws dashed lines above and below, with no side padding. Good between paragraphs.

[ ROUTES ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank title="ROUTES" frame="rule">

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

none

frame="none" drops the border and the padding. The title sits above the content.

[ ROUTES ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank title="ROUTES" frame="none">

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

none, untitled

Leave out title and only the figure is left.

  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank frame="none">

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

box, untitled

Every frame works without a title. Pass title="" to drop a default title, like the type on a Callout.

  1. /docs12,400
  2. /install4,100
  3. /plot860
<GraphRank>

- 12,400 /docs
- 4,100 /install
- 860 /plot

</GraphRank>

one frame for a page

GraphFrameProvider sets the frame for every graph inside it. A graph's own frame prop still wins.

[ ROUTES ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
[ OVERRIDE ]
  1. /docs12,400
  2. /install4,100
  3. /plot860
:root {
  --graph-accent: oklch(0.5 0.14 228);
  --graph-accent-2: oklch(0.48 0.18 259);
  --graph-accent-3: oklch(0.5 0.14 248);
}

.dark {
  --graph-accent: oklch(0.77 0.15 228);
  --graph-accent-2: oklch(0.68 0.18 259);
  --graph-accent-3: oklch(0.72 0.15 248);
}

import { GraphFrameProvider } from "@/registry/default/graph-frame/graph-frame"

export default function Layout({ children }: { children: React.ReactNode }) {
  return <GraphFrameProvider frame="none">{children}</GraphFrameProvider>
}

titled frame

Compose Graph, GraphTitle, GraphBody, and GraphRule.

[ USAGE ]

Content goes inside the frame.

Same dashed border as the other graphs.

import {
  Graph,
  GraphBody,
  GraphRule,
} from "@/registry/default/graph-frame/graph-frame"

<Graph title="USAGE">
  <GraphBody className="flex flex-col gap-4">
    <p>Content goes inside the frame.</p>
    <GraphRule />
    <p className="text-graph-muted">Same dashed border as the other graphs.</p>
  </GraphBody>
</Graph>

untitled

Skip title and the top edge stays a dashed line. corner swaps the +.

Corners still sit on the frame. Caption is optional.

import { Graph, GraphBody } from "@/registry/default/graph-frame/graph-frame"

<Graph corner="*">
  <GraphBody>
    <p>Corners still sit on the frame. Caption is optional.</p>
  </GraphBody>
</Graph>
[ PROPS ]
PropTypeDefaultDescription
titlestring—Optional caption. Renders as [ TITLE ] on the top edge, or above the content when frame is none. Pass an empty string to drop a component's default title.
cornerstring"+"Character at each corner. Default +.
frame"box" | "corners" | "rule" | "none""box"box draws the dashed border. corners keeps only the corner marks. rule draws dashed lines above and below. none drops the border and padding, and puts the title above the content.
classNamestring—Passed to the figure.
childrenReactNode—Usually GraphBody.