Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Text Rotate

    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>
    import { Component } from "@angular/core";
    import { TextRotate } from "./markas/text-rotate.component";
    
    @Component({
      selector: "markas-example",
      imports: [TextRotate],
      template: `
        <h2 class="text-3xl font-semibold tracking-tight text-ink">
          Build for
          <span markas-text-rotate [words]="words" class="text-muted"></span>
        </h2>
      `,
    })
    export default class TextRotateExample {
      protected readonly words = ["Laravel", "React", "Vue"];
    }

    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.

    Hiring badge

    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 Dewi Lestari, Budi Santoso, Siti Aminah, Rizal Hakim

    Installation

    npx markasui@latest add text-rotate

    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

    NameTypeDefaultDescription
    wordsstring[]-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.
    intervalnumber2500Milliseconds between two words.
    staggernumber25Milliseconds between one unit and the next.
    durationnumber400Milliseconds each unit takes to leave or enter. The width follows over the same time.
    pauseOnHoverbooleantrueHold 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.