Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Text Rotate

    Kata atau frasa yang bergiliran, keluar dan masuk per huruf atau per kata dengan stagger dari bagian pertama, terakhir, tengah, atau acak.

    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"];
    }

    Contoh

    Judul hero

    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.

    Badge lowongan

    Nama tim dengan urutan acak

    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

    Instalasi

    npx markasui@latest add text-rotate

    Pemakaian

    <h1 class="text-4xl font-semibold">
        Bangun untuk
        <x-markas.text-rotate :words="['Laravel', 'React', 'Vue']" />
    </h1>
    <x-markas.text-rotate :words="['lebih cepat', 'dengan yakin', 'setiap Jumat']" split="words" from="center" :interval="3000" />
    import { TextRotate } from "@/components/markas/TextRotate";
    
    <h1 className="text-4xl font-semibold">
      Bangun untuk <TextRotate words={["Laravel", "React", "Vue"]} />
    </h1>
    <TextRotate words={['lebih cepat', 'dengan yakin', 'setiap Jumat']} split="words" from="center" interval={3000} />
    <template>
      <h1 class="text-4xl font-semibold">
        Bangun untuk
        <TextRotate :words="['Laravel', 'React', 'Vue']" />
      </h1>
      <TextRotate
        :words="['lebih cepat', 'dengan yakin', 'setiap Jumat']"
        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">
      Bangun untuk <TextRotate words={["Laravel", "React", "Vue"]} />
    </h1>
    <TextRotate
      words={["lebih cepat", "dengan yakin", "setiap Jumat"]}
      split="words"
      from="center"
      interval={3000}
    />
    ---
    import TextRotate from "@/components/markas/TextRotate.astro";
    ---
    
    <h1 class="text-4xl font-semibold">
      Bangun untuk <TextRotate words={["Laravel", "React", "Vue"]} />
    </h1>
    <TextRotate
      words={["lebih cepat", "dengan yakin", "setiap Jumat"]}
      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">
          Bangun untuk
          <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 = ["lebih cepat", "dengan yakin", "setiap Jumat"];
    }

    Angular memakai attribute selector pada span, jadi class dan aria-* jatuh ke elemen akar. Astro merender kata pertama di server lalu memutarnya dengan script kecil.

    • Kata lama keluar ke atas bagian demi bagian, lalu kata berikutnya naik masuk, dan lebar pembungkus ikut berubah halus.
    • Putaran berhenti saat hover (matikan dengan pauseOnHover), saat teks di luar layar, dan saat tab tersembunyi.
    • Screen reader membaca setiap kata sekali, dipisah koma, dan tidak ada pengumuman di setiap giliran.
    • Dengan reduced motion, kata pertama tetap tampil. Versi Blade butuh Alpine.js.

    Props

    NamaTipeDefaultKeterangan
    wordsstring[]-Kata atau frasa yang tampil bergiliran. Yang pertama dirender di server.
    split"chars" | "words""chars"Animasikan setiap huruf atau setiap kata.
    from"first" | "last" | "center" | "random""first"Titik awal stagger. random memakai urutan acak yang tetap.
    intervalnumber2500Milidetik di antara dua kata.
    staggernumber25Milidetik antara satu bagian dan bagian berikutnya.
    durationnumber400Milidetik yang dibutuhkan setiap bagian untuk keluar atau masuk. Lebar ikut berubah dalam waktu yang sama.
    pauseOnHoverbooleantrueTahan kata yang tampil selama kursor berada di atasnya.

    Aksesibilitas

    • Screen reader membaca semua kata sekali dari salinan tersembunyi yang dipisah koma; bagian yang bergerak memakai aria-hidden dan tidak ada pengumuman di setiap giliran.
    • Putaran berhenti saat hover, saat teks di luar layar, dan saat tab tersembunyi.
    • Dengan reduced motion, kata pertama tetap tampil dan tidak berputar.

    Komponen terkait

    Komponen animasi lain dengan class yang sama di setiap framework.