组件

Arrow

A hand-drawn arrow that points where you tell it: one of eight directions inside its own box, or straight at another element on the page. Straight, curved, or with a loop-the-loop, five heads, and an optional label.

安装

terminal
npx shadcn@latest add @wobko/arrow

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

示例

Default

A straight arrow in its 80 x 40 box. The tail sits a hair lower than the head, like a real one.

Directions, shafts and heads

Eight directions, each straight and curved; then the curl and the five heads.

Pointing at an element

Give it a ref (or a selector) and the arrow leaves its small box and stops just short of the target, wherever the layout puts it. Resize the window and it follows.

With a label

Text inside an Arrow is its label: real handwritten text, placed outside the tail on the side the arrow leaves from. Here it leaves the note at the top right and lands on the signature line.

API 参考

Arrow

A <span> that fills its box (`className` sizes it, default 80 x 40) with the drawing. Text inside becomes a label, real text placed outside the tail. The svg is aria-hidden and never takes a click.

属性类型默认值说明
direction"right" | "left" | "up" | "down" | "up-right" | "up-left" | "down-right" | "down-left""right"Which way it points, inside its own box.
curve"straight" | "curved" | "curl""straight"A straight shaft, one lazy arc, or an arc with a loop-the-loop.
head"v" | "two" | "open" | "solid" | "none""v"The arrowhead: two strokes joined, two loose strokes, an open V, a filled triangle, or none.
tone"ink" | "blue" | "red" | "green" | "pencil" | "marker" | "orange""ink"The pen. Blue felt is the reserved "you" ink.
weight"fine" | "regular" | "brush""regular"Fine-liner, felt tip or brush.
bend"up" | "down""up"Which way a curved shaft bulges: toward the top (the left for a vertical arrow) or the bottom (the right).
pointAtRefObject<Element> | Element | string-Aim at another element (a ref, an element or a CSS selector). The arrow leaves the middle of its own box and stops `gap` px short of the target, wherever that is; it follows layout changes.
gapnumber6With pointAt, how far short of the target the head stops, px.
mirrorbooleantrueFlip horizontal directions in a right-to-left page, so "next" keeps meaning onwards.
animatebooleanfalseDraw the arrow on, shaft first, the first time it scrolls into view.
showbooleantrueShow or hide it.
delaynumber-Milliseconds before the drawing starts.
seedstring | number-Pins the hand.

无障碍

  • Decorative: the drawing is aria-hidden and pointer-events-none. If the arrow says something ("start here"), put it in text; a label given as children is real text.
  • It never affects layout: the box is yours, the drawing may spill 14 px beyond it (or as far as the target with pointAt).
  • Windows high contrast hides the drawing, like every overlay ink; the label stays.
  • Reduced motion zeroes the draw-on.

源码

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

正在加载源码