组件

Marquee

A ticker written on a strip of washi tape. The text runs along it, fades at the ends, stops while you point at it or focus inside it, and has a pause button. With reduced motion it is a still strip with the text centered.

安装

terminal
npx shadcn@latest add @wobko/marquee

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

示例

Default

Point at it and it stops; so does Tab. The round button pauses it for good.

Tapes and directions

Any tape from the desk: masking, striped, gingham. direction="end" runs it the other way, speed sets px per second. (washi-dots is for short, large words: its white dots are as big as small letters.)

Announcement bar

A real use: the strip above a site header, with links in it. Only the first copy can be tabbed to, and the ticker holds still while a link has focus.

API 参考

Marquee

The band: a strip of the engine's tape drawn to the width of the box, with the moving text in a clipped, edge-faded viewport. It repeats its content just enough times to fill the band and loops seamlessly with a CSS animation (keyframes come with the component).

属性类型默认值说明
speednumber60px per second. A short text is never slower than a 4 second loop.
direction"start" | "end""start"Toward the start of the line (like a news ticker, mirrored in right-to-left) or away from it.
tape / colorTapeKind / Accent"washi-stripes"masking, washi-dots, washi-stripes, washi-zigzag, washi-gingham, kraft or clear; color is the print of a washi. `washi-dots` has white dots as big as small letters: keep it for short, large words and put customer names on `washi-gingham`, `washi-stripes` or `masking`.
paused / defaultPaused / onPausedChangeboolean-Controlled or uncontrolled pause. Hover and keyboard focus pause it as well.
controlsbooleantrueThe pause button. Leave it on for any ticker that runs more than five seconds.
labelstring"Ticker"Accessible name (role="marquee").

MarqueeItem

One phrase, followed by a small hand-drawn star. Pass `separator` for your own glyph, or `false` for none.

属性类型默认值说明
separatorReactNode | false-What comes after the phrase.

无障碍

  • Only the first copy of the text is exposed; every repeat is aria-hidden and inert, so a screen reader reads the ticker once and Tab does not visit links twice.
  • It pauses on hover and while focus is inside it (WCAG 2.2.2), and the pause button has aria-pressed. The button is on by default; do not remove it for a ticker that moves for more than five seconds.
  • Reduced motion (the OS setting or data-motion="reduced"): the animation is off, the repeats are hidden and the one copy is centered on the tape.
  • Put the words that matter in the first copy in the DOM order you want them read; the ticker itself is role="marquee", which assistive technology treats as a non-live region.
  • Ink on the default orange washi is 7:1 and on the dotted and gingham tapes above 6:1. The text is 24 px semibold script with a paper halo (a CSS text-shadow), so it holds on patterned tape; keep phrases short, and use `masking` when the words are long.
  • A short phrase on a wide screen is repeated as often as it takes to fill the band (at most 48 copies, all but the first hidden and inert).

源码

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

正在加载源码