Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Text Scramble

    Text that scrambles into random characters, then decodes letter by letter. Runs on hover, when it scrolls into view, or on mount.

    Project codename

    Operation Nusantara

    Open the brief

    Project codename

    Operation Nusantara

    Open the brief

    Project codename

    Operation Nusantara

    Open the brief

    Project codename

    Operation Nusantara

    Open the brief

    Project codename

    Operation Nusantara

    Open the brief
    <div class="rounded-xl border border-line bg-surface p-6">
        <p class="text-sm text-muted">Project codename</p>
        <h2 class="mt-1 text-3xl font-semibold tracking-tight text-ink">
            <x-markas.text-scramble text="Operation Nusantara" trigger="view" />
        </h2>
        <a href="#" class="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"><x-markas.text-scramble text="Open the brief" charset="symbols" /></a>
    </div>
    import { TextScramble } from "@/components/markas/TextScramble";
    
    export default function TextScrambleExample() {
      return (
        <div className="rounded-xl border border-line bg-surface p-6">
          <p className="text-sm text-muted">Project codename</p>
          <h2 className="mt-1 text-3xl font-semibold tracking-tight text-ink">
            <TextScramble text="Operation Nusantara" trigger="view" />
          </h2>
          <a
            href="#"
            className="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
          >
            <TextScramble text="Open the brief" charset="symbols" />
          </a>
        </div>
      );
    }
    <script setup lang="ts">
    import TextScramble from "@/components/markas/TextScramble.vue";
    </script>
    
    <template>
      <div class="rounded-xl border border-line bg-surface p-6">
        <p class="text-sm text-muted">Project codename</p>
        <h2 class="mt-1 text-3xl font-semibold tracking-tight text-ink">
          <TextScramble text="Operation Nusantara" trigger="view" />
        </h2>
        <a
          href="#"
          class="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
          ><TextScramble text="Open the brief" charset="symbols"
        /></a>
      </div>
    </template>
    <script lang="ts">
      import TextScramble from "$lib/components/markas/TextScramble.svelte";
    </script>
    
    <div class="rounded-xl border border-line bg-surface p-6">
      <p class="text-sm text-muted">Project codename</p>
      <h2 class="mt-1 text-3xl font-semibold tracking-tight text-ink">
        <TextScramble text="Operation Nusantara" trigger="view" />
      </h2>
      <!-- svelte-ignore a11y_invalid_attribute -->
      <a
        href="#"
        class="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
      >
        <TextScramble text="Open the brief" charset="symbols" />
      </a>
    </div>
    ---
    import TextScramble from "@/components/markas/TextScramble.astro";
    ---
    
    <div class="rounded-xl border border-line bg-surface p-6">
      <p class="text-sm text-muted">Project codename</p>
      <h2 class="mt-1 text-3xl font-semibold tracking-tight text-ink">
        <TextScramble text="Operation Nusantara" trigger="view" />
      </h2>
      <a
        href="#"
        class="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
      >
        <TextScramble text="Open the brief" charset="symbols" />
      </a>
    </div>
    import { Component } from "@angular/core";
    import { TextScramble } from "./markas/text-scramble.component";
    
    @Component({
      selector: "markas-example",
      imports: [TextScramble],
      template: `
        <div class="rounded-xl border border-line bg-surface p-6">
          <p class="text-sm text-muted">Project codename</p>
          <h2 class="mt-1 text-3xl font-semibold tracking-tight text-ink">
            <span
              markas-text-scramble
              text="Operation Nusantara"
              trigger="view"
            ></span>
          </h2>
          <a
            href="#"
            class="mt-4 inline-flex h-9 items-center rounded-lg border border-line px-3 font-mono text-sm text-ink hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
          >
            <span
              markas-text-scramble
              text="Open the brief"
              charset="symbols"
            ></span>
          </a>
        </div>
      `,
    })
    export default class TextScrambleExample {}

    Examples

    Stats in sequence

    Revenue

    Rp 12,4 M

    Uptime

    99.98%

    Active teams

    1,284

    Revenue

    Rp 12,4 M

    Uptime

    99.98%

    Active teams

    1,284

    Revenue

    Rp 12,4 M

    Uptime

    99.98%

    Active teams

    1,284

    Revenue

    Rp 12,4 M

    Uptime

    99.98%

    Active teams

    1,284

    Revenue

    Rp 12,4 M

    Uptime

    99.98%

    Active teams

    1,284

    Terminal

    $ markas auth --token

    Handshake 0110 1011 0010

    Access granted

    $ markas auth --token

    Handshake 0110 1011 0010

    Access granted

    $ markas auth --token

    Handshake 0110 1011 0010

    Access granted

    $ markas auth --token

    Handshake 0110 1011 0010

    Access granted

    $ markas auth --token

    Handshake 0110 1011 0010

    Access granted

    Studio navbar

    Installation

    npx markasui@latest add text-scramble

    Usage

    <h2 class="text-3xl font-semibold">
        <x-markas.text-scramble text="Operation Nusantara" trigger="view" />
    </h2>
    <x-markas.text-scramble text="Rp 12,4 M" trigger="view" charset="digits" />
    <x-markas.text-scramble text="99.98%" trigger="view" charset="digits" :delay="150" />
    <a href="/brief"><x-markas.text-scramble text="Open the brief" charset="symbols" /></a>
    import { TextScramble } from "@/components/markas/TextScramble";
    
    <h2 className="text-3xl font-semibold">
      <TextScramble text="Operation Nusantara" trigger="view" />
    </h2>
    <TextScramble text="Rp 12,4 M" trigger="view" charset="digits" />
    <TextScramble text="99.98%" trigger="view" charset="digits" delay={150} />
    <a href="/brief"><TextScramble text="Open the brief" charset="symbols" /></a>
    <template>
      <h2 class="text-3xl font-semibold">
        <TextScramble text="Operation Nusantara" trigger="view" />
      </h2>
      <TextScramble text="Rp 12,4 M" trigger="view" charset="digits" />
      <TextScramble text="99.98%" trigger="view" charset="digits" :delay="150" />
      <a href="/brief"><TextScramble text="Open the brief" charset="symbols" /></a>
    </template>
    <script lang="ts">
      import TextScramble from "$lib/components/markas/TextScramble.svelte";
    </script>
    
    <h2 class="text-3xl font-semibold">
      <TextScramble text="Operation Nusantara" trigger="view" />
    </h2>
    <TextScramble text="99.98%" trigger="view" charset="digits" delay={150} />
    <a href="/brief"><TextScramble text="Open the brief" charset="symbols" /></a>
    ---
    import TextScramble from "@/components/markas/TextScramble.astro";
    ---
    
    <h2 class="text-3xl font-semibold">
      <TextScramble text="Operation Nusantara" trigger="view" />
    </h2>
    <TextScramble text="99.98%" trigger="view" charset="digits" delay={150} />
    <a href="/brief"><TextScramble text="Open the brief" charset="symbols" /></a>
    import { Component } from "@angular/core";
    import { TextScramble } from "./markas/text-scramble.component";
    
    @Component({
      selector: "app-stats",
      imports: [TextScramble],
      template: `
        <h2 class="text-3xl font-semibold">
          <span
            markas-text-scramble
            text="Operation Nusantara"
            trigger="view"
          ></span>
        </h2>
        <span
          markas-text-scramble
          text="99.98%"
          trigger="view"
          charset="digits"
          delay="150"
        ></span>
        <a href="/brief">
          <span markas-text-scramble text="Open the brief" charset="symbols"></span>
        </a>
      `,
    })
    export class Stats {}

    Angular uses an attribute selector on a span: <span markas-text-scramble>. In Astro the text is rendered on the server and a small script scrambles it.

    • hover runs on hover and focus of the closest link or button. view and mount start scrambled and decode once; view waits until the text scrolls into view.
    • An invisible copy of the final text holds the width, so the layout never shifts while scrambling.
    • The random characters come from a seeded generator, so every run looks the same in every framework.
    • Screen readers hear only the final text. With reduced motion, the final text is shown and never scrambles. The Blade version needs Alpine.js.

    Props

    NameTypeDefaultDescription
    textstring-The final text. It is rendered on the server and is what screen readers hear.
    trigger"hover" | "view" | "mount""hover"hover runs on hover and focus of the closest link or button, view runs once when the text scrolls into view, mount runs right away.
    charset"letters" | "digits" | "symbols" | "binary""letters"Characters used while scrambling.
    durationnumber800Milliseconds from fully scrambled to fully decoded.
    delaynumber0Milliseconds to stay scrambled before decoding starts, for view and mount. Use rising delays to decode a row of stats in sequence.

    Accessibility

    • Screen readers hear the final text once from a visually hidden copy; the scrambled layer is aria-hidden.
    • An invisible copy of the final text keeps the width fixed, so nothing around it shifts.
    • With reduced motion, the final text is shown and never scrambles.

    Related components

    More animations components with the same classes in every framework.