Words or phrases that take turns, animating out and in per letter or per word with a stagger from the first, last, center, or a shuffled unit.
Build for Laravel, React, Vue
Build for Laravel, React, Vue
Build for Laravel, React, Vue
Build for Laravel, React, Vue
Build for Laravel, React, Vue
<h2 class="text-3xl font-semibold tracking-tight text-ink">
Build for <x-markas.text-rotate :words="['Laravel', 'React', 'Vue']" class="text-muted" />
</h2>import { TextRotate } from "@/components/markas/TextRotate";
export default function TextRotateExample() {
return (
<h2 className="text-3xl font-semibold tracking-tight text-ink">
Build for{" "}
<TextRotate words={["Laravel", "React", "Vue"]} className="text-muted" />
</h2>
);
}<script setup lang="ts">
import TextRotate from "@/components/markas/TextRotate.vue";
</script>
<template>
<h2 class="text-3xl font-semibold tracking-tight text-ink">
Build for
<TextRotate :words="['Laravel', 'React', 'Vue']" class="text-muted" />
</h2>
</template><script lang="ts">
import TextRotate from "$lib/components/markas/TextRotate.svelte";
</script>
<h2 class="text-3xl font-semibold tracking-tight text-ink">
Build for <TextRotate
words={["Laravel", "React", "Vue"]}
class="text-muted"
/>
</h2>---
import TextRotate from "@/components/markas/TextRotate.astro";
---
<h2 class="text-3xl font-semibold tracking-tight text-ink">
Build for <TextRotate words={["Laravel", "React", "Vue"]} class="text-muted" />
</h2>Examples
Hero headline
Ship faster, with confidence, every Friday
One component library for Blade, React, and Vue.
Ship faster, with confidence, every Friday
One component library for Blade, React, and Vue.
Ship faster, with confidence, every Friday
One component library for Blade, React, and Vue.
Ship faster, with confidence, every Friday
One component library for Blade, React, and Vue.
Ship faster, with confidence, every Friday
One component library for Blade, React, and Vue.
<div class="py-4 text-center">
<h2 class="text-4xl font-semibold tracking-tight text-ink">
Ship <x-markas.text-rotate :words="['faster', 'with confidence', 'every Friday']" split="words" from="center" class="rounded-lg bg-primary px-3 text-on-primary" />
</h2>
<p class="mx-auto mt-4 max-w-sm text-sm text-muted">One component library for Blade, React, and Vue.</p>
</div>Hiring badge
<div class="flex justify-center">
<a href="#" class="inline-flex items-center gap-2 rounded-full border border-line bg-surface py-1 pr-3 pl-1 text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary">
<span class="rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium">Now hiring</span>
<x-markas.text-rotate :words="['designers', 'engineers', 'writers']" from="last" :interval="2000" />
</a>
</div>Team names in random order
Reviewed by Dewi Lestari, Budi Santoso, Siti Aminah, Rizal Hakim
Reviewed by Dewi Lestari, Budi Santoso, Siti Aminah, Rizal Hakim
Reviewed by Dewi Lestari, Budi Santoso, Siti Aminah, Rizal Hakim
Reviewed by Dewi Lestari, Budi Santoso, Siti Aminah, Rizal Hakim
Reviewed by
<div class="flex items-center gap-3 rounded-xl border border-line bg-surface p-4">
<span aria-hidden="true" class="grid size-10 place-items-center rounded-full bg-subtle text-sm font-medium text-ink">MU</span>
<p class="text-sm text-muted">Reviewed by <x-markas.text-rotate :words="['Dewi Lestari', 'Budi Santoso', 'Siti Aminah', 'Rizal Hakim']" from="random" class="font-medium text-ink" /></p>
</div>Installation
npx markasui@latest add text-rotatepnpm dlx markasui@latest add text-rotateyarn dlx markasui@latest add text-rotatebunx --bun markasui@latest add text-rotate- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/text-rotate.blade.php.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/TextRotate.tsx.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/TextRotate.vue.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/TextRotate.svelte.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/TextRotate.astro.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/text-rotate.component.ts.
Usage
<h1 class="text-4xl font-semibold">
Build for
<x-markas.text-rotate :words="['Laravel', 'React', 'Vue']" />
</h1>
<x-markas.text-rotate :words="['faster', 'with confidence', 'every Friday']" split="words" from="center" :interval="3000" />import { TextRotate } from "@/components/markas/TextRotate";
<h1 className="text-4xl font-semibold">
Build for <TextRotate words={["Laravel", "React", "Vue"]} />
</h1>
<TextRotate words={['faster', 'with confidence', 'every Friday']} split="words" from="center" interval={3000} /><template>
<h1 class="text-4xl font-semibold">
Build for
<TextRotate :words="['Laravel', 'React', 'Vue']" />
</h1>
<TextRotate
:words="['faster', 'with confidence', 'every Friday']"
split="words"
from="center"
:interval="3000"
/>
</template><script lang="ts">
import TextRotate from "$lib/components/markas/TextRotate.svelte";
</script>
<h1 class="text-4xl font-semibold">
Build for <TextRotate words={["Laravel", "React", "Vue"]} />
</h1>
<TextRotate
words={["faster", "with confidence", "every Friday"]}
split="words"
from="center"
interval={3000}
/>---
import TextRotate from "@/components/markas/TextRotate.astro";
---
<h1 class="text-4xl font-semibold">
Build for <TextRotate words={["Laravel", "React", "Vue"]} />
</h1>
<TextRotate
words={["faster", "with confidence", "every Friday"]}
split="words"
from="center"
interval={3000}
/>import { Component } from "@angular/core";
import { TextRotate } from "./markas/text-rotate.component";
@Component({
selector: "app-hero",
imports: [TextRotate],
template: `
<h1 class="text-4xl font-semibold">
Build for
<span markas-text-rotate [words]="stacks"></span>
</h1>
<span
markas-text-rotate
[words]="phrases"
split="words"
from="center"
interval="3000"
></span>
`,
})
export class Hero {
protected readonly stacks = ["Laravel", "React", "Vue"];
protected readonly phrases = ["faster", "with confidence", "every Friday"];
}Angular uses an attribute selector on a span, so class and aria-* land on the root. Astro renders the first word on the server and rotates it with a small script.
- The old word leaves upward unit by unit, then the next one rises in, and the width of the wrapper follows smoothly.
- The rotation pauses on hover (turn it off with
pauseOnHover), when the text is off screen, and when the tab is hidden. - Screen readers hear every word once, joined with commas, and nothing is announced on each turn.
- With reduced motion, the first word stays. The Blade version needs Alpine.js.
Props
| Name | Type | Default | Description |
|---|---|---|---|
words | string[] | - | Words or phrases shown in turn. The first one is rendered on the server. |
split | "chars" | "words" | "chars" | Animate each letter or each word. |
from | "first" | "last" | "center" | "random" | "first" | Where the stagger starts. random uses a fixed shuffled order. |
interval | number | 2500 | Milliseconds between two words. |
stagger | number | 25 | Milliseconds between one unit and the next. |
duration | number | 400 | Milliseconds each unit takes to leave or enter. The width follows over the same time. |
pauseOnHover | boolean | true | Hold the current word while the pointer is over it. |
Accessibility
- Screen readers read all words once from a visually hidden copy, joined with commas; the animated units are aria-hidden and nothing is announced on each turn.
- The rotation pauses on hover, when the text is off screen, and when the tab is hidden.
- With reduced motion, the first word stays and does not rotate.
Related components
More animations components with the same classes in every framework.
- Avatar GroupOverlapping stack of avatars that spreads out on hover, shows each name in a tooltip, and collapses extra people into a +N chip.
- Letter SwapText whose letters slide out and back in with a stagger when its link or button is hovered or focused. Forward, ping-pong, or shuffled order.
- MarqueeEndless horizontal or vertical scroll of any content, with faded edges, reverse direction, and a pause on hover or focus.
- Number TickerNumber that counts up to its value when it scrolls into view, with thousands separators, decimals, and a prefix or suffix.
- Scroll ProgressThin bar at the top of the page or a scrolling container that fills as the reader scrolls.
- Spotlight CardCard with a soft radial light that follows the pointer and a border that glows near it. Lights up on keyboard focus too.