「テキストリビール」は Pro に含まれます。解除するとプレビューが表示されます。
仕組み
Text is first split into words and spaces, using Intl.Segmenter when available. Punctuation joins a neighbouring word so it never starts a line. In character mode, each CJK character is a group and each Latin word is one non-breaking group animated letter by letter. Pieces are inline-block with one --i variable and the delay is a CSS calc. The animation uses backwards fill, so no filter remains.
向いている場面
- Headlines and hero text on landing pages.
- Short statements that should be read one beat at a time.
- Text that should appear only when it scrolls into view (trigger="inView").
向かない場面
- Long paragraphs: the reveal takes too long and slows reading.
- Text people must read at once, such as errors and prices.
- Content that updates often: every change would replay the animation.
使い方
import { TextReveal } from './TextReveal.jsx'
export function Hero() {
return (
<>
<TextReveal as="h1" text="Make every moment count" split="char" stagger={40} />
<TextReveal as="p" text="Plan, track and share your days" split="word" delay={300} trigger="inView" />
</>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
text | string | — | The text to show. It may contain line breaks (\n). |
as | 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'span' | 'div' | 'p' | Tag to render. |
split | 'char' | 'word' | 'char' | How to split: by character or by word (Chinese is grouped into words, falling back to characters without Intl.Segmenter). |
stagger | number | 40 | Interval between neighbouring pieces, in ms. |
duration | number | 560 | Reveal time of each piece, in ms. |
delay | number | 0 | Delay before the whole reveal starts, in ms. |
blur | boolean | true | Whether to include a 6px to 0 blur. |
distance | number | string | '0.35em' | Rise distance; numbers are px. |
trigger | 'mount' | 'inView' | 'mount' | Play on mount, or when scrolled into view (only once). |
replayKey | Key | — | Changing it plays the reveal again. |
locale | string | 'zh-CN' | Language used to split words. It does not change the text. |
onComplete | () => void | — | Called when the last piece finishes revealing. |
...rest | HTMLAttributes<HTMLElement> | — | Other attributes go to the root element, such as className, style and id. |
アクセシビリティ
- Screen readers read one complete hidden copy of the text; all split pieces are aria-hidden.
- The hidden copy cannot be selected, so copying text does not produce it twice.
- Reduced motion shows the text at once, and onComplete is still called.
- Waiting pieces stay hidden instead of flashing before they play.
- Keep contrast and size as for any text; the effect never changes the final look.
モーション
Each piece takes 560ms ease-out (cubic-bezier(0.16, 1, 0.3, 1)), 40ms apart; it rises 0.35em and un-blurs from 6px to 0.
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
TextReveal.jsxtext-reveal.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。



