组件

Callout

A note in the margin: a few handwritten words and a hand arrow pointing at the thing they are about. It is an ordinary box, so put it where it belongs with a class: float it into the margin, absolutely position it, or drop it in a grid cell.

安装

terminal
npx shadcn@latest add @wobko/callout

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Default

Handwritten words and an arrow that points left, at whatever is to their left.

Eight directions

The arrow points where you say; the words sit on its tail.

In the margin of a paragraph

Float a callout into the page's padding (`float-end clear-end -me-56`) right after the words it is about: it lands on that line, whatever the width. Below md they are hidden.

A hint on a form

Positioned with className over a form: a hint that points at the field it is about, that writes itself on when the form scrolls into view and goes away when you dismiss it.

API 参考

Callout

A <span role="note"> with the words (written with a little per-word jitter) and an Arrow. `direction` is where the arrow POINTS, so a note on the right of a paragraph points left. The words sit on the arrow's tail side.

属性类型默认值说明
direction"left" | "right" | "up" | "down" | "up-left" | "up-right" | "down-left" | "down-right""left"Where the arrow points, so where the thing you are talking about is.
curve"straight" | "curved" | "curl""curved"The shaft of the arrow.
head"v" | "two" | "open" | "solid" | "none""v"The arrowhead.
tone"blue" | "ink" | "red" | "green" | "pencil" | "marker" | "orange""blue"The pen of the arrow. Blue felt is the reserved "you" ink and the natural one for notes.
weight"fine" | "regular" | "brush""regular"Fine-liner, felt tip or brush.
bend"up" | "down""up"Which way a curved arrow bulges.
arrowbooleantrueDraw the arrow. Without it the callout is just handwritten words.
arrowClassNamestring"h-10 w-14"Sizes the arrow.
animatebooleanfalseWrite the note on when it first scrolls into view: the words fade in, the arrow draws itself.
showbooleantrueShow or hide the note.
delaynumber-Milliseconds before the note starts to appear.
seedstring | number-Pins the hand of the words and the arrow.

无障碍

  • role="note": announced as a note. The words are real text; the arrow is aria-hidden.
  • A margin note should add to the page, not carry it: keep the essential information in the main text.
  • The margin pattern (`float-end clear-end -me-56 w-48`) needs room in the page's padding; below the md breakpoint hide it (`max-md:hidden`) or let it flow.
  • Per-word jitter is switched off by calm density and reduced motion; the arrow draws on with the same rules as Arrow.

源码

CLI 会复制进你项目的文件。

正在加载源码