组件

Annotate

One component for every mark, in the spirit of RoughNotation: put a highlight, an underline, a circle, a box, brackets, a strike, a cross-out or a scribble on real words, and draw it on when it scrolls into view.

安装

terminal
npx shadcn@latest add @wobko/annotate

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

示例

Playground: a reader's page

One paragraph annotated the way a reader does it: a circle, two highlighters, a red underline, a struck phrase, a wavy line and margin notes with arrows. Switch each on and off, or replay the whole page being marked up.

Every type

The eight marks side by side. Each is a real component underneath (Highlight, Underline, Circled, Strike, Scribble) with the same props.

Colors and weights

A highlighter takes a tone; every other mark takes a pen. Fine-liner, felt tip or brush.

An editor's pass

Turn the review on and the draft is marked up in sequence: words crossed out, a phrase scribbled, another bracketed. Nothing is removed from the text.

API 参考

Annotate

Renders the matching mark (Highlight, Underline, Circled, Strike or Scribble) for `type`, so every behavior of those applies: the words stay text, the drawing is aria-hidden and follows line breaks, and `animate` writes it on the first time it scrolls into view.

属性类型默认值说明
type"highlight" | "underline" | "circle" | "box" | "brackets" | "strike-through" | "crossed-off" | "scribble"-Which mark to put on the words.
colorHighlightTone | MarkPen-For highlight: yellow, pink, green, blue, orange, lilac or teal. For everything else: ink, blue, red, green, pencil, marker or orange.
weight"fine" | "regular" | "brush""regular"Fine-liner, felt tip or brush pen (a highlighter is held light, regular or heavy).
kind"single" | "double" | "wavy" | "scribble""single"The line of an underline. Ignored by the other types.
showbooleantrueShow or hide the mark. With animate, turning it on plays the draw-on again.
animatebooleanfalseHold the mark back and draw it on the first time the words scroll into view. Reduced motion just shows it.
delaynumber-Milliseconds before the drawing starts.
seedstring | number-Pins the hand. Default: derived from useId(), so server and client draw the same marks.

无障碍

  • The words are ordinary text: selectable, copyable, found by search and read in order. Every drawing is aria-hidden and pointer-events-none.
  • A mark that carries meaning (the right answer, a price that changed) needs the meaning in words as well; a drawing alone is not announced.
  • Highlight is a <mark>, strike-through is an <s>. Before the drawing exists, without JavaScript, and in Windows high contrast, the browser's own decoration shows instead.
  • Reduced motion (or data-motion="reduced") zeroes the draw-on: marks simply appear.

源码

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

正在加载源码