Performance
À surveillerFréquence d'images: 60 i/s en moyenne, p5 59.9 · Tâches longues: 0 tâches, 0 ms au total, plus longue 0 ms · Source gzip 8.7 KB · À l'exécution 189 KB
Roll TextMITEffet de texteAnimata
Composant React Effet de texte par Animata. Repris sans modification depuis Animata sous licence MIT et présenté ici en direct.
Rapport qualite
La note et le score proviennent de contrôles automatiques lancés à la compilation ou aux tests. Si un contrôle n'a pas été exécuté, il est indiqué Non testé — aucun chiffre n'est inventé.
Fréquence d'images: 60 i/s en moyenne, p5 59.9 · Tâches longues: 0 tâches, 0 ms au total, plus longue 0 ms · Source gzip 8.7 KB · À l'exécution 189 KB
Problemes 0 · Lecteur d'écran: Reussi
Pas de mouvement continu
Pas de debordement
La fréquence d'images et les tâches longues ont été mesurées dans Chromium sans interface, avec un WebGL logiciel. Elles ne sont comparables qu'entre composants de ce site, et ne représentent pas un appareil réel.
Sans objet : aucune animation visible au repos. Les animations déclenchées au survol n'ont pas été testées.
Aucune violation axe-core.

Controle le 15 nov. 2026 · Les chiffres viennent d'un script automatique, pas d'exemples ecrits a la main.
Affiché à taille réelle.
La copie commence par la notice de licence. Gardez-la lorsque vous utilisez le code.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:"Paper Mono", ui-monospace, monospace;--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-500:oklch(79.5% .184 86.047);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-500:oklch(62.3% .214 259.815);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-950:oklch(14.1% .005 285.823);--spacing:.25rem;--container-xs:20rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5 / 2.25);--font-weight-medium:500;--tracking-tight:-.025em;--radius-xl:.75rem;--ease-out:cubic-bezier(.22, 1, .36, 1);--default-transition-duration:.2s;--default-transition-timing-function:var(--ease-out);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-border:hsl(var(--border));--color-background:hsl(var(--background));--color-foreground:hsl(var(--foreground));--color-muted:hsl(var(--muted));--color-muted-foreground:hsl(var(--muted-foreground));--ease-apple:cubic-bezier(.4, 0, .6, 1)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--color-border)}body{background-color:var(--color-background);color:var(--color-foreground)}:root{--background:0 0% 100%;--foreground:0 0% 11%;--card:0 0% 100%;--card-foreground:0 0% 11%;--popover:0 0% 100%;--popover-foreground:0 0% 11%;--primary:0 0% 11%;--primary-foreground:0 0% 100%;--secondary:0 0% 96%;--secondary-foreground:0 0% 11%;--muted:0 0% 96%;--muted-foreground:0 0% 43%;--accent:262 83% 58%;--accent-foreground:0 0% 100%;--destructive:0 84% 60%;--destructive-foreground:0 0% 98%;--border:0 0% 90%;--input:0 0% 90%;--ring:262 83% 58%;--radius:.75rem;--surface-alt:0 0% 96%;--surface-card:0 0% 100%;--surface-dark:0 0% 7%;--text-secondary:0 0% 43%;--ink:#76756f;--ink-faint:#e3e3e3;--link:210 100% 40%;--link-hover:210 100% 32%;--shadow-sm:0 1px 2px #0000000d;--shadow-md:0 2px 8px #0000000f, 0 4px 16px #0000000a;--shadow-lg:0 4px 12px #0000000f, 0 12px 32px #00000014;--footer-surface:#f5f5f7;--footer-ink:#0f1d42;--footer-ink-muted:#1a2d5c;--footer-accent:#1a4fff;--footer-gold:#fc0;--footer-category-title:#1d1d1f;--footer-category-link:#515154;--footer-stamp:#9f9f9f}.dark{--background:0 0% 0%;--foreground:0 0% 96%;--card:0 0% 4%;--card-foreground:0 0% 96%;--popover:0 0% 4%;--popover-foreground:0 0% 96%;--primary:0 0% 96%;--primary-foreground:0 0% 0%;--secondary:0 0% 10%;--secondary-foreground:0 0% 96%;--muted:0 0% 10%;--muted-foreground:0 0% 45%;--accent:262 83% 65%;--accent-foreground:0 0% 100%;--destructive:0 62% 30%;--destructive-foreground:0 0% 98%;--border:0 0% 12%;--input:0 0% 12%;--ring:262 83% 65%;--surface-alt:0 0% 4%;--surface-card:0 0% 6%;--surface-dark:0 0% 2%;--text-secondary:0 0% 55%;--ink:#e3e3e3;--ink-faint:#76756f;--link:262 80% 70%;--link-hover:262 80% 80%;--shadow-sm:none;--shadow-md:none;--shadow-lg:none;--footer-surface:#1d1d1f;--footer-ink:#f5f5f7;--footer-ink-muted:#86868b;--footer-accent:#fc0;--footer-gold:#fc0;--footer-category-title:#f5f5f7;--footer-category-link:#86868b;--footer-stamp:#48484a}}@layer components{.text-animator-demo .text-animation-stage,[data-text-animator-demo] .text-animation-stage{perspective:900px;padding:clamp(1rem,5cqi,1.5rem);font-size:clamp(1rem,10cqi,2rem);font-weight:500;line-height:1.1}.text-animator-demo .text-animation-title,.text-animator-demo .text-animation-kinetic-word,[data-text-animator-demo] .text-animation-title,[data-text-animator-demo] .text-animation-kinetic-word{text-align:center;letter-spacing:-.025em}.text-animator-demo .text-animation-title,[data-text-animator-demo] .text-animation-title{text-wrap:balance;font-variant-numeric:tabular-nums}.roll-text{--roll-duration:.45s;--roll-duration-reduced:.15s;--roll-ease:cubic-bezier(.77, 0, .175, 1);--roll-line-height:1;font-kerning:none;line-height:var(--roll-line-height)}.roll-text:focus-visible{outline:2px solid hsl(var(--ring));outline-offset:3px}.roll-text__track{line-height:inherit;white-space:pre;display:inline}.roll-unit{clip-path:inset(0);contain:paint;vertical-align:baseline;font-kerning:none;line-height:inherit;display:inline-grid;position:relative;overflow:clip}.roll-unit__sizer,.roll-unit__stack{line-height:inherit;grid-area:1/1}.roll-unit__sizer{visibility:hidden;pointer-events:none;-webkit-user-select:none;user-select:none;white-space:pre}.roll-unit__stack{white-space:pre;inset-inline:0;flex-direction:column;display:flex;position:absolute;top:0;transform:translateY(0)}.roll-unit__line{line-height:inherit;white-space:inherit;display:block}@keyframes roll-stack-open{0%{transform:translateY(0)}to{transform:translateY(-50%)}}.roll-text--animating .roll-unit__stack{animation:roll-stack-open var(--roll-unit-duration,var(--roll-duration)) var(--roll-ease) var(--roll-delay,0s) forwards}.roll-text--open:not(.roll-text--animating) .roll-unit__stack{transform:translateY(-50%)}@media (prefers-reduced-motion:reduce){.roll-text--animating .roll-unit__stack{animation-duration:var(--roll-duration-reduced)}}}@layer utilities{.pointer-events-none{pointer-events:none}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.step{counter-increment:step}.step:before{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);border-style:var(--tw-border-style);border-width:4px;border-color:var(--color-background);background-color:var(--color-muted);text-align:center;text-indent:-1px;font-family:var(--font-mono);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);content:counter(step);border-radius:2147483647px;justify-content:center;align-items:center;margin-top:-4px;margin-left:-50px;display:inline-flex;position:absolute}.relative{position:relative}.mt-2{margin-top:calc(var(--spacing) * 2)}.block{display:block}.inline-block{display:inline-block}.max-w-xs{max-width:var(--container-xs)}.cursor-default{cursor:default}.rounded-xl{border-radius:var(--radius-xl)}.p-5{padding:calc(var(--spacing) * 5)}.font-\(family-name\:--font-display\){font-family:var(--font-display)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.text-foreground{color:var(--color-foreground)}.text-muted-foreground{color:var(--color-muted-foreground)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-foreground\/10{--tw-ring-color:color-mix(in srgb, hsl(var(--foreground)) 10%, transparent)}@supports (color:color-mix(in lab, red, red)){.ring-foreground\/10{--tw-ring-color:color-mix(in oklab, var(--color-foreground) 10%, transparent)}}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.hover\:bg-foreground\/\[0\.02\]:hover{background-color:color-mix(in srgb, hsl(var(--foreground)) 2%, transparent)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-foreground\/\[0\.02\]:hover{background-color:color-mix(in oklab, var(--color-foreground) 2%, transparent)}}}@keyframes orbit-move{0%{transform:translate(-50%,-50%)rotateY(-40deg)rotateX(70deg)rotate(0)translate(100px)}to{transform:translate(-50%,-50%)rotateY(-40deg)rotateX(70deg)rotate(360deg)translate(100px)}}@keyframes counter-rotate{0%{opacity:1;transform:rotate(0)rotateX(-70deg)rotateY(40deg)scale(1)}25%{opacity:1;transform:rotate(-90deg)rotateX(-70deg)rotateY(40deg)scale(1.2)}50%{opacity:.3;transform:rotate(-180deg)rotateX(-70deg)rotateY(40deg)scale(.8)}75%{opacity:.3;transform:rotate(-270deg)rotateX(-70deg)rotateY(40deg)scale(.8)}to{opacity:1;transform:rotate(-360deg)rotateX(-70deg)rotateY(40deg)scale(1)}}@keyframes orbit-indexes{0%,25%,to{z-index:11}50%,99%{z-index:9}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}.preview{margin-bottom:calc(var(--spacing) * 4)}.preview-light{background-color:#fefefe;background-image:radial-gradient(#efefef 1px,#0000 1px),radial-gradient(#efefef 1px,#0000 1px);background-position:0 0,10px 10px;background-size:20px 20px}.preview-dark{background-image:radial-gradient(#6a6a6a 1px,#0000 1px),radial-gradient(#6a6a6a 1px,#0000 1px);background-position:0 0,10px 10px;background-size:20px 20px}.component-list-item{border-color:var(--color-zinc-200);background-color:#fefefe;background-image:radial-gradient(#efefef 1px,#0000 1px),radial-gradient(#efefef 1px,#0000 1px);background-position:0 0,10px 10px;background-size:20px 20px}.dark .component-list-item{border-color:var(--color-zinc-700);background-color:var(--color-zinc-950);background-image:radial-gradient(#6a6a6a 1px,#0000 1px),radial-gradient(#6a6a6a 1px,#0000 1px);background-position:0 0,10px 10px;background-size:20px 20px}[style*="opacity: 1"]>.scroll-baby{color:var(--color-yellow-300)}[style*="opacity: 1"]>.scroll-baby:where(.dark,.dark *){color:var(--color-yellow-500)}[style*="opacity: 1"]>.scroll-file{color:var(--color-blue-300)}[style*="opacity: 1"]>.scroll-file:where(.dark,.dark *){color:var(--color-blue-500)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}// animata source (MIT). npm i clsx react tailwind-merge · Tailwind CSS v4
// ── animata/text/roll-text.css (https://github.com/codse/animata/blob/25c27e5a874c60a56dcc1609df3b2c4f5f8456f8/animata/text/roll-text.css)
@layer components {
.roll-text {
--roll-duration: 450ms;
--roll-duration-reduced: 150ms;
--roll-ease: cubic-bezier(0.77, 0, 0.175, 1);
--roll-line-height: 1;
font-kerning: none;
line-height: var(--roll-line-height);
}
.roll-text:focus-visible {
outline: 2px solid hsl(var(--ring));
outline-offset: 3px;
}
.roll-text__track {
display: inline;
line-height: inherit;
white-space: pre;
}
/* inline-grid + clip keeps the text baseline (from the sizer in row 1)
while clipping the translated stack. Prefer clip-path/contain over plain
overflow:hidden — sticky headers with backdrop-filter promote compositing
layers that can let transformed children paint outside overflow:hidden. */
.roll-unit {
position: relative;
display: inline-grid;
overflow: clip;
clip-path: inset(0);
contain: paint;
vertical-align: baseline;
font-kerning: none;
line-height: inherit;
}
.roll-unit__sizer,
.roll-unit__stack {
grid-area: 1 / 1;
line-height: inherit;
}
.roll-unit__sizer {
visibility: hidden;
pointer-events: none;
user-select: none;
white-space: pre;
}
.roll-unit__stack {
position: absolute;
inset-inline: 0;
top: 0;
display: flex;
flex-direction: column;
white-space: pre;
transform: translateY(0);
}
.roll-unit__line {
display: block;
line-height: inherit;
white-space: inherit;
}
@keyframes roll-stack-open {
from {
transform: translateY(0);
}
to {
transform: translateY(-50%);
}
}
.roll-text--animating .roll-unit__stack {
animation: roll-stack-open var(--roll-unit-duration, var(--roll-duration)) var(--roll-ease)
var(--roll-delay, 0ms) forwards;
}
.roll-text--open:not(.roll-text--animating) .roll-unit__stack {
transform: translateY(-50%);
}
@media (prefers-reduced-motion: reduce) {
.roll-text--animating .roll-unit__stack {
animation-duration: var(--roll-duration-reduced);
}
}
}
// ── animata/text/roll-text.tsx (https://github.com/codse/animata/blob/25c27e5a874c60a56dcc1609df3b2c4f5f8456f8/animata/text/roll-text.tsx)
"use client";
import type React from "react";
import {
Fragment,
memo,
useCallback,
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from "react";
import { cn } from "@/lib/utils";
import "./roll-text.css";
export type RollStagger = "none" | "word" | "character";
export interface RollTextProps extends Omit<React.ComponentPropsWithoutRef<"span">, "children"> {
/** Label duplicated across the two stacked roll layers. */
text: string;
/**
* When true, the roll plays when the nearest `[data-roll-group]` or
* `group/roll` ancestor receives hover or focus. The span is not tabbable —
* put `href` / actions on the wrapping link or button.
* @default false
*/
groupHover?: boolean;
/**
* When true, hover and focus do not trigger the roll — use for active nav
* items or other states where motion should stay static.
* @default false
*/
disabled?: boolean;
/**
* Stagger the roll across words or characters. `none` animates the whole
* label at once.
* @default "none"
*/
stagger?: RollStagger;
/** Delay step between staggered units in ms. @default 32 */
staggerMs?: number;
/** Per-unit travel duration in ms. @default 250 */
durationMs?: number;
}
type RollPhase = "closed" | "animating" | "open";
type RollSegment = {
key: string;
value: string;
delay: number;
duration: number;
};
function staggerDelay(index: number, count: number, staggerMs: number): number {
if (count <= 1) return 0;
return index * staggerMs;
}
function segmentTiming(
index: number,
count: number,
staggerMs: number,
durationMs: number,
): { delay: number; duration: number } {
return {
delay: staggerDelay(index, count, staggerMs),
duration: durationMs,
};
}
function splitSegments(
text: string,
stagger: RollStagger,
staggerMs: number,
durationMs: number,
): RollSegment[] {
if (stagger === "none") {
return [{ key: "whole", value: text, delay: 0, duration: durationMs }];
}
if (stagger === "word") {
const words = text.trim().split(/\s+/);
return words.map((word, index) => {
const timing = segmentTiming(index, words.length, staggerMs, durationMs);
return {
key: `${index}-${word}`,
value: word,
...timing,
};
});
}
return [...text].map((char, index) => {
const timing = segmentTiming(index, text.length, staggerMs, durationMs);
return {
key: `${index}-${char}`,
value: char,
...timing,
};
});
}
const ROLL_GROUP_SELECTOR = "[data-roll-group], .group\\/roll";
function findRollGroup(node: HTMLElement | null) {
return node?.closest(ROLL_GROUP_SELECTOR) ?? null;
}
const RollUnit = memo(function RollUnit({
segment,
onStackAnimationEnd,
}: {
segment: RollSegment;
onStackAnimationEnd?: (event: React.AnimationEvent<HTMLSpanElement>) => void;
}) {
return (
<span
className="roll-unit"
style={
{
"--roll-delay": `${segment.delay}ms`,
"--roll-unit-duration": `${segment.duration}ms`,
} as React.CSSProperties
}
>
<span className="roll-unit__sizer" aria-hidden>
{segment.value}
</span>
<span className="roll-unit__stack" aria-hidden onAnimationEnd={onStackAnimationEnd}>
<span className="roll-unit__line">{segment.value}</span>
<span className="roll-unit__line">{segment.value}</span>
</span>
</span>
);
});
/**
* Decorative roll label — always a `span`. Wrap in `<a>`, `<Link>`, or `<button>`
* for navigation or actions.
*/
export default function RollText({
text,
groupHover = false,
disabled = false,
stagger = "none",
staggerMs = 32,
durationMs = 250,
className,
tabIndex,
style,
onMouseEnter,
onFocus,
onAnimationEnd,
...props
}: RollTextProps) {
const segments = useMemo(
() => splitSegments(text, stagger, staggerMs, durationMs),
[text, stagger, staggerMs, durationMs],
);
const rootRef = useRef<HTMLSpanElement>(null);
const phaseRef = useRef<RollPhase>("closed");
const disabledRef = useRef(disabled);
const segmentCountRef = useRef(segments.length);
const remainingRef = useRef(0);
const reducedMotionRef = useRef(false);
const [phase, setPhase] = useState<RollPhase>("closed");
const resolvedTabIndex = tabIndex ?? (groupHover ? undefined : 0);
segmentCountRef.current = segments.length;
disabledRef.current = disabled;
if (disabled && phase !== "closed") {
setPhase("closed");
}
useEffect(() => {
phaseRef.current = phase;
}, [phase]);
useEffect(() => {
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
reducedMotionRef.current = media.matches;
const onChange = (event: MediaQueryListEvent) => {
reducedMotionRef.current = event.matches;
};
media.addEventListener("change", onChange);
return () => media.removeEventListener("change", onChange);
}, []);
const playOpen = useCallback(() => {
if (disabledRef.current || phaseRef.current === "animating") return;
if (reducedMotionRef.current) {
setPhase("open");
return;
}
remainingRef.current = segmentCountRef.current;
if (phaseRef.current === "open") {
setPhase("closed");
requestAnimationFrame(() => {
requestAnimationFrame(() => setPhase("animating"));
});
return;
}
setPhase("animating");
}, []);
useLayoutEffect(() => {
if (!groupHover || disabled) return;
const node = rootRef.current;
const group = findRollGroup(node);
if (!group) return;
group.addEventListener("mouseenter", playOpen);
group.addEventListener("focusin", playOpen);
return () => {
group.removeEventListener("mouseenter", playOpen);
group.removeEventListener("focusin", playOpen);
};
}, [groupHover, disabled, playOpen]);
const handleMouseEnter = (event: React.MouseEvent<HTMLSpanElement>) => {
onMouseEnter?.(event);
if (!groupHover && !disabled) playOpen();
};
const handleFocus = (event: React.FocusEvent<HTMLSpanElement>) => {
onFocus?.(event);
if (!groupHover && !disabled) playOpen();
};
const handleStackAnimationEnd = useCallback(
(event: React.AnimationEvent<HTMLSpanElement>) => {
onAnimationEnd?.(event);
if (phaseRef.current !== "animating") return;
remainingRef.current -= 1;
if (remainingRef.current <= 0) setPhase("open");
},
[onAnimationEnd],
);
return (
<span
ref={rootRef}
tabIndex={resolvedTabIndex}
className={cn(
"roll-text relative inline-block cursor-default",
phase === "animating" && "roll-text--animating",
phase === "open" && "roll-text--open",
className,
)}
style={
{
...style,
"--roll-duration": `${durationMs}ms`,
} as React.CSSProperties
}
onMouseEnter={handleMouseEnter}
onFocus={handleFocus}
{...props}
>
<span className="sr-only">{text}</span>
<span className="roll-text__track select-none" aria-hidden>
{segments.map((segment, index) => (
<Fragment key={segment.key}>
{stagger === "word" && index > 0 ? " " : null}
<RollUnit segment={segment} onStackAnimationEnd={handleStackAnimationEnd} />
</Fragment>
))}
</span>
</span>
);
}
// ── lib/utils.ts (https://github.com/codse/animata/blob/25c27e5a874c60a56dcc1609df3b2c4f5f8456f8/lib/utils.ts)
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function absoluteUrl(path: string) {
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`;
}
// Linear interpolation
export function lerp(a: number, b: number, n: number) {
return (1 - n) * a + n * b;
}
// Get distance between two points
export function getDistance(x1: number, y1: number, x2: number, y2: number) {
return Math.hypot(x2 - x1, y2 - y1);
}Réglages · HTML · CSS · JS
Modifiez le code et ajustez-le avec les réglages. L'aperçu se met à jour pendant la saisie.

Ce composant tourne depuis un bundle compilé : son script est en lecture seule ici. Modifiez le HTML et le CSS ; la source complète est dans l'onglet Code.
Modifiez chaque composant en direct, ajustez-le avec des réglages, téléchargez la source complète et copiez les prompts avancés.
49 $ en une foisPrix provisoire
Mode test : aucun paiement réel.
Gratuit : aperçu, boutons de copie et notes de leçon.
Au survol, l'étiquette s'enroule comme une machine à sous et le même texte apparaît par le bas, éventuellement échelonné par mot ou par caractère.
Liens de navigation, boutons et éléments de menu.
Définissez le décalage (aucun, mot ou caractère), staggerMs, durationMs et groupHover pour le déclencher à partir d'un parent.
Ajoute le composant « Faire défiler le texte au survol » de Animata (github.com/codse/animata) (MIT) à mon application React + Tailwind CSS. Fichier source : https://github.com/codse/animata/blob/25c27e5a874c60a56dcc1609df3b2c4f5f8456f8/animata/text/roll-text.tsx. Au survol, l'étiquette s'enroule comme une machine à sous et le même texte apparaît par le bas, éventuellement échelonné par mot ou par caractère. À utiliser pour : Liens de navigation, boutons et éléments de menu. Réglages à ajuster : Définissez le décalage (aucun, mot ou caractère), staggerMs, durationMs et groupHover pour le déclencher à partir d'un parent. Prends en charge les thèmes clair et sombre et respecte prefers-reduced-motion. Conserve la mention de licence MIT.
Un prompt plus long avec les étapes de réglage, d'accessibilité et d'intégration.