Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Text Highlighter

    Sorotan di balik teks inline yang tergambar dari empat arah: saat masuk layar, hover atau fokus, mount, atau perintah. Solid, stabilo, garis bawah, gradien.

    Set the measure first

    Long lines tire the eye, so readers lose their place on the way back. Keep body text at 45 to 75 characters per line, give it a line height near 1.5, and let headings sit closer to the text they introduce than to the one above.

    Set the measure first

    Long lines tire the eye, so readers lose their place on the way back. Keep body text at 45 to 75 characters per line, give it a line height near 1.5, and let headings sit closer to the text they introduce than to the one above.

    Set the measure first

    Long lines tire the eye, so readers lose their place on the way back. Keep body text at 45 to 75 characters per line, give it a line height near 1.5, and let headings sit closer to the text they introduce than to the one above.

    Set the measure first

    Long lines tire the eye, so readers lose their place on the way back. Keep body text at 45 to 75 characters per line, give it a line height near 1.5, and let headings sit closer to the text they introduce than to the one above.

    Set the measure first

    Long lines tire the eye, so readers lose their place on the way back. Keep body text at 45 to 75 characters per line, give it a line height near 1.5, and let headings sit closer to the text they introduce than to the one above.

    <article class="text-base leading-7 text-muted">
        <h3 class="text-lg font-semibold text-ink">Set the measure first</h3>
        <p class="mt-2">Long lines tire the eye, so readers lose their place on the way back. Keep body text at <x-markas.text-highlighter>45 to 75 characters</x-markas.text-highlighter> per line, give it a <x-markas.text-highlighter :delay="400">line height near 1.5</x-markas.text-highlighter>, and let headings sit <x-markas.text-highlighter :delay="800">closer to the text they introduce</x-markas.text-highlighter> than to the one above.</p>
    </article>
    import { TextHighlighter } from "@/components/markas/TextHighlighter";
    
    export default function TextHighlighterExample() {
      return (
        <article className="text-base leading-7 text-muted">
          <h3 className="text-lg font-semibold text-ink">Set the measure first</h3>
          <p className="mt-2">
            Long lines tire the eye, so readers lose their place on the way back.
            Keep body text at <TextHighlighter>45 to 75 characters</TextHighlighter>{" "}
            per line, give it a{" "}
            <TextHighlighter delay={400}>line height near 1.5</TextHighlighter>, and
            let headings sit{" "}
            <TextHighlighter delay={800}>
              closer to the text they introduce
            </TextHighlighter>{" "}
            than to the one above.
          </p>
        </article>
      );
    }
    <script setup lang="ts">
    import TextHighlighter from "@/components/markas/TextHighlighter.vue";
    </script>
    
    <template>
      <article class="text-base leading-7 text-muted">
        <h3 class="text-lg font-semibold text-ink">Set the measure first</h3>
        <p class="mt-2">
          Long lines tire the eye, so readers lose their place on the way back. Keep
          body text at
          <TextHighlighter>45 to 75 characters</TextHighlighter> per line, give it a
          <TextHighlighter :delay="400">line height near 1.5</TextHighlighter>, and
          let headings sit
          <TextHighlighter :delay="800"
            >closer to the text they introduce</TextHighlighter
          >
          than to the one above.
        </p>
      </article>
    </template>
    <script lang="ts">
      import TextHighlighter from "$lib/components/markas/TextHighlighter.svelte";
    </script>
    
    <article class="text-base leading-7 text-muted">
      <h3 class="text-lg font-semibold text-ink">Set the measure first</h3>
      <p class="mt-2">
        Long lines tire the eye, so readers lose their place on the way back. Keep
        body text at
        <TextHighlighter>45 to 75 characters</TextHighlighter> per line, give it a
        <TextHighlighter delay={400}>line height near 1.5</TextHighlighter>, and let
        headings sit
        <TextHighlighter delay={800}
          >closer to the text they introduce</TextHighlighter
        >
        than to the one above.
      </p>
    </article>
    ---
    import TextHighlighter from "@/components/markas/TextHighlighter.astro";
    ---
    
    <article class="text-base leading-7 text-muted">
      <h3 class="text-lg font-semibold text-ink">Set the measure first</h3>
      <p class="mt-2">
        Long lines tire the eye, so readers lose their place on the way back. Keep
        body text at{" "}
        <TextHighlighter>45 to 75 characters</TextHighlighter>{" "}
        per line, give it a{" "}
        <TextHighlighter delay={400}>line height near 1.5</TextHighlighter>, and
        let headings sit{" "}
        <TextHighlighter delay={800}>closer to the text they introduce</TextHighlighter>{" "}
        than to the one above.
      </p>
    </article>
    import { Component } from "@angular/core";
    import { TextHighlighter } from "./markas/text-highlighter.component";
    
    @Component({
      selector: "markas-example",
      imports: [TextHighlighter],
      template: `
        <article class="text-base leading-7 text-muted">
          <h3 class="text-lg font-semibold text-ink">Set the measure first</h3>
          <p class="mt-2">
            Long lines tire the eye, so readers lose their place on the way back.
            Keep body text at
            <span markas-text-highlighter>45 to 75 characters</span> per line, give
            it a
            <span markas-text-highlighter delay="400">line height near 1.5</span>,
            and let headings sit
            <span markas-text-highlighter delay="800"
              >closer to the text they introduce</span
            >
            than to the one above.
          </p>
        </article>
      `,
    })
    export default class TextHighlighterExample {}

    Contoh

    Empat arah saat hover

    Dikontrol tombol

    Before you publish, check that the title fits in 60 characters, every image has alt text, and the summary answers one clear question.

    Before you publish, check that the title fits in 60 characters, every image has alt text, and the summary answers one clear question.

    Before you publish, check that the title fits in 60 characters, every image has alt text, and the summary answers one clear question.

    Before you publish, check that the title fits in 60 characters, every image has alt text, and the summary answers one clear question.

    Before you publish, check that the title fits in 60 characters, every image has alt text, and the summary answers one clear question.

    Stabilo di judul hero

    Ship your design system before the next sprint

    One set of components for Blade, React, and Vue, with tokens your team already knows.

    Ship your design system before the next sprint

    One set of components for Blade, React, and Vue, with tokens your team already knows.

    Ship your design system before the next sprint

    One set of components for Blade, React, and Vue, with tokens your team already knows.

    Ship your design system before the next sprint

    One set of components for Blade, React, and Vue, with tokens your team already knows.

    Ship your design system before the next sprint

    One set of components for Blade, React, and Vue, with tokens your team already knows.

    Solid, stabilo, garis bawah, gradien

    • A solid block for quotes worth saving.
    • A marker stroke for notes in the margin.
    • A thick underline for terms to remember.
    • A two tone gradient for the headline idea.
    • A solid block for quotes worth saving.
    • A marker stroke for notes in the margin.
    • A thick underline for terms to remember.
    • A two tone gradient for the headline idea.
    • A solid block for quotes worth saving.
    • A marker stroke for notes in the margin.
    • A thick underline for terms to remember.
    • A two tone gradient for the headline idea.
    • A solid block for quotes worth saving.
    • A marker stroke for notes in the margin.
    • A thick underline for terms to remember.
    • A two tone gradient for the headline idea.
    • A solid block for quotes worth saving.
    • A marker stroke for notes in the margin.
    • A thick underline for terms to remember.
    • A two tone gradient for the headline idea.

    Instalasi

    npx markasui@latest add text-highlighter

    Pemakaian

    <p>Jaga teks isi di <x-markas.text-highlighter>45 sampai 75 karakter</x-markas.text-highlighter> per baris, dengan <x-markas.text-highlighter variant="marker" :delay="400">tinggi baris sekitar 1,5</x-markas.text-highlighter>.</p>
    
    <a href="/docs"><x-markas.text-highlighter trigger="hover" direction="rtl" color="success">Baca dokumentasi</x-markas.text-highlighter></a>
    
    <div x-data>
        <x-markas.text-highlighter trigger="manual">Siap terbit</x-markas.text-highlighter>
        <button type="button" x-on:click="$dispatch('markas-highlight', { direction: 'ltr' })">Sorot</button>
        <button type="button" x-on:click="$dispatch('markas-highlight-reset')">Ulang</button>
    </div>
    import { useRef } from "react";
    import {
      TextHighlighter,
      type TextHighlighterHandle,
    } from "@/components/markas/TextHighlighter";
    
    const highlight = useRef<TextHighlighterHandle>(null);
    
    <p>
      Jaga teks isi di <TextHighlighter>45 sampai 75 karakter</TextHighlighter> per
      baris, dengan{" "}
      <TextHighlighter variant="marker" delay={400}>
        tinggi baris sekitar 1,5
      </TextHighlighter>
      .
    </p>
    
    <TextHighlighter ref={highlight} trigger="manual">Siap terbit</TextHighlighter>
    <button type="button" onClick={() => highlight.current?.animate("rtl")}>Sorot</button>
    <button type="button" onClick={() => highlight.current?.reset()}>Ulang</button>
    <script setup lang="ts">
    import { ref } from "vue";
    import TextHighlighter from "@/components/markas/TextHighlighter.vue";
    
    const active = ref(false);
    </script>
    
    <template>
      <p>
        Jaga teks isi di
        <TextHighlighter>45 sampai 75 karakter</TextHighlighter> per baris, dengan
        <TextHighlighter variant="marker" :delay="400"
          >tinggi baris sekitar 1,5</TextHighlighter
        >.
      </p>
      <TextHighlighter trigger="manual" :active="active"
        >Siap terbit</TextHighlighter
      >
      <button type="button" @click="active = !active">Ganti</button>
    </template>
    <script lang="ts">
      import TextHighlighter from "$lib/components/markas/TextHighlighter.svelte";
    
      let active = $state(false);
    </script>
    
    <p>
      Keep body text at <TextHighlighter>45 to 75 characters</TextHighlighter> per line,
      with a
      <TextHighlighter variant="marker" delay={400}
        >line height near 1.5</TextHighlighter
      >.
    </p>
    <TextHighlighter trigger="manual" {active}>Ready to publish</TextHighlighter>
    <button type="button" onclick={() => (active = !active)}>Toggle</button>
    ---
    import TextHighlighter from "@/components/markas/TextHighlighter.astro";
    ---
    
    <p>
      Keep body text at <TextHighlighter>45 to 75 characters</TextHighlighter> per
      line, with a{" "}
      <TextHighlighter variant="marker" delay={400}>line height near 1.5</TextHighlighter>.
    </p>
    <TextHighlighter trigger="manual">Ready to publish</TextHighlighter>
    <button
      type="button"
      onclick="window.dispatchEvent(new CustomEvent('markas-highlight'))"
    >
      Highlight
    </button>
    import { Component, signal } from "@angular/core";
    import { TextHighlighter } from "./markas/text-highlighter.component";
    
    @Component({
      selector: "app-checklist",
      imports: [TextHighlighter],
      template: `
        <p>
          Keep body text at
          <span markas-text-highlighter>45 to 75 characters</span> per line, with a
          <mark markas-text-highlighter variant="marker" delay="400"
            >line height near 1.5</mark
          >.
        </p>
        <span markas-text-highlighter trigger="manual" [active]="active()"
          >Ready to publish</span
        >
        <button type="button" (click)="active.set(!active())">Toggle</button>
      `,
    })
    export class Checklist {
      active = signal(false);
    }
    • Sorotan adalah gradien latar yang tumbuh lewat transisi CSS background-size, sehingga ikut terpotong rapi di setiap baris (box-decoration-break: clone).
    • trigger="view" memakai IntersectionObserver dengan once dan threshold; hover mendengar link, tombol, label, atau elemen ber-tabindex terdekat, sehingga fokus keyboard juga menggambar sorotan.
    • Untuk trigger="manual", React dan Vue mengekspos animate(direction?) dan reset() lewat ref. Blade mendengar event window markas-highlight (dengan direction opsional di detail) dan markas-highlight-reset, dan Alpine.$data(el) mengekspos dua method yang sama. Svelte mengeksposnya lewat bind:this, Astro mendengar event window yang sama dengan Blade dan mengekspos highlight(direction?) dan reset() di elemen markas-text-highlighter, dan Angular mengeksposnya lewat #mark="markasTextHighlighter".
    • Angular tidak punya input as: pasang atribut markas-text-highlighter di elemen yang diinginkan, misalnya span, strong, atau mark.
    • duration dan delay dipasang sebagai transition-duration dan transition-delay pada elemen. Beri setiap frasa delay yang lebih besar untuk menyorot paragraf sesuai urutan baca.
    • Dengan reduced motion, sorotan view dan auto langsung tampil, dan setiap perubahan terjadi tanpa transisi.

    Props

    NamaTipeDefaultKeterangan
    asstring"span"Elemen yang dirender. Tetap inline, misalnya span, strong, atau mark. Angular: pasang atribut markas-text-highlighter di elemen itu.
    trigger"view" | "hover" | "auto" | "manual""view"view menggambar saat teks masuk layar, hover mengikuti hover dan fokus keyboard pada link atau tombol terdekat, auto menggambar saat mount, manual mengikuti active.
    direction"ltr" | "rtl" | "ttb" | "btt""ltr"Arah tumbuh sorotan: kiri ke kanan, kanan ke kiri, atas ke bawah, atau bawah ke atas.
    variant"solid" | "marker" | "underline" | "gradient""solid"solid mengisi baris, marker menutup 60% bagian bawah seperti stabilo, underline menggambar garis tebal di bawah teks, gradient memadukan dua token.
    color"warning" | "primary" | "primary-soft" | "success" | "danger""warning"Token warna sorotan, dicampur transparansi agar teks tetap terbaca.
    activebooleanfalseKeadaan sorotan untuk trigger manual.
    oncebooleantruetrigger view: gambar sekali, atau hapus lagi saat teks keluar layar.
    thresholdnumber0.5trigger view: seberapa banyak teks harus terlihat, dari 0 sampai 1.
    durationnumber700Milidetik yang dibutuhkan sorotan untuk tergambar.
    delaynumber0Milidetik menunggu sebelum menggambar. Pakai delay bertingkat untuk menyorot paragraf berurutan.

    Aksesibilitas

    • Teks tetap teks biasa; sorotan adalah gambar latar dan tidak diumumkan.
    • Teks di atas sorotan memakai token ink sehingga kontras AA terjaga di tema terang dan gelap.
    • trigger hover juga merespons fokus keyboard pada link, tombol, atau elemen fokus terdekat.
    • Dengan reduced motion, sorotan view dan auto langsung tampil dan setiap perubahan terjadi tanpa transisi.

    Komponen terkait

    Komponen animasi lain dengan class yang sama di setiap framework.