Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Image Trail

    Area tempat gambar, kartu, atau emoji muncul di sepanjang jalur kursor lalu memudar, mengecil, berputar, atau menumpuk. Bisa menggambar jejaknya sendiri.

    Move your cursor here

    Color cards follow the pointer and fade away

    Move your cursor here

    Color cards follow the pointer and fade away

    Move your cursor here

    Color cards follow the pointer and fade away

    Move your cursor here

    Color cards follow the pointer and fade away

    Move your cursor here

    Color cards follow the pointer and fade away

    @php
        $area = 'grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center';
        $cards = [
            'block h-20 w-16 rounded-lg bg-primary',
            'block h-20 w-16 rounded-lg bg-success',
            'block h-20 w-16 rounded-lg bg-warning',
            'block h-20 w-16 rounded-lg bg-danger',
            'block h-20 w-16 rounded-lg bg-primary-soft',
        ];
        $title = 'text-lg font-semibold text-ink';
        $hint = 'mt-1 text-sm text-muted';
    @endphp
    
    <x-markas.image-trail :class="$area">
        <x-slot:items>
            @foreach ($cards as $card)
                <span class="{{ $card }}"></span>
            @endforeach
        </x-slot:items>
        <p class="{{ $title }}">Move your cursor here</p>
        <p class="{{ $hint }}">Color cards follow the pointer and fade away</p>
    </x-markas.image-trail>
    import { ImageTrail } from "@/components/markas/ImageTrail";
    
    const area =
      "grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center";
    const cards = [
      "block h-20 w-16 rounded-lg bg-primary",
      "block h-20 w-16 rounded-lg bg-success",
      "block h-20 w-16 rounded-lg bg-warning",
      "block h-20 w-16 rounded-lg bg-danger",
      "block h-20 w-16 rounded-lg bg-primary-soft",
    ];
    const title = "text-lg font-semibold text-ink";
    const hint = "mt-1 text-sm text-muted";
    
    export default function ImageTrailExample() {
      return (
        <ImageTrail
          className={area}
          items={cards.map((card) => (
            <span key={card} className={card}></span>
          ))}
        >
          <p className={title}>Move your cursor here</p>
          <p className={hint}>Color cards follow the pointer and fade away</p>
        </ImageTrail>
      );
    }
    <script setup lang="ts">
    import ImageTrail from "@/components/markas/ImageTrail.vue";
    
    const area =
      "grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center";
    const cards = [
      "block h-20 w-16 rounded-lg bg-primary",
      "block h-20 w-16 rounded-lg bg-success",
      "block h-20 w-16 rounded-lg bg-warning",
      "block h-20 w-16 rounded-lg bg-danger",
      "block h-20 w-16 rounded-lg bg-primary-soft",
    ];
    const title = "text-lg font-semibold text-ink";
    const hint = "mt-1 text-sm text-muted";
    </script>
    
    <template>
      <ImageTrail :class="area">
        <template #items>
          <span v-for="card in cards" :key="card" :class="card"></span>
        </template>
        <p :class="title">Move your cursor here</p>
        <p :class="hint">Color cards follow the pointer and fade away</p>
      </ImageTrail>
    </template>
    <script lang="ts">
      import ImageTrail from "$lib/components/markas/ImageTrail.svelte";
    
      const area =
        "grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center";
      const cards = [
        "block h-20 w-16 rounded-lg bg-primary",
        "block h-20 w-16 rounded-lg bg-success",
        "block h-20 w-16 rounded-lg bg-warning",
        "block h-20 w-16 rounded-lg bg-danger",
        "block h-20 w-16 rounded-lg bg-primary-soft",
      ];
      const title = "text-lg font-semibold text-ink";
      const hint = "mt-1 text-sm text-muted";
    </script>
    
    <ImageTrail class={area}>
      {#snippet items()}
        {#each cards as card (card)}<span class={card}></span>{/each}
      {/snippet}
      <p class={title}>Move your cursor here</p>
      <p class={hint}>Color cards follow the pointer and fade away</p>
    </ImageTrail>
    ---
    import ImageTrail from "@/components/markas/ImageTrail.astro";
    
    const area =
      "grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center";
    const cards = [
      "block h-20 w-16 rounded-lg bg-primary",
      "block h-20 w-16 rounded-lg bg-success",
      "block h-20 w-16 rounded-lg bg-warning",
      "block h-20 w-16 rounded-lg bg-danger",
      "block h-20 w-16 rounded-lg bg-primary-soft",
    ];
    const title = "text-lg font-semibold text-ink";
    const hint = "mt-1 text-sm text-muted";
    ---
    
      <ImageTrail class={area}>
        <Fragment slot="items">
          {cards.map((card) => (<span class={card}></span>))}
        </Fragment>
        <p class={title}>Move your cursor here</p>
        <p class={hint}>Color cards follow the pointer and fade away</p>
      </ImageTrail>
    import { Component } from "@angular/core";
    import { ImageTrail } from "./markas/image-trail.component";
    
    @Component({
      selector: "markas-example",
      imports: [ImageTrail],
      template: `
        <markas-image-trail [class]="area">
          <ng-container items>
            @for (card of cards; track card) {
              <span [class]="card"></span>
            }
          </ng-container>
          <p [class]="title">Move your cursor here</p>
          <p [class]="hint">Color cards follow the pointer and fade away</p>
        </markas-image-trail>
      `,
    })
    export default class ImageTrailExample {
      protected readonly area =
        "grid h-72 content-center justify-items-center rounded-xl border border-line bg-subtle p-6 text-center";
      protected readonly cards = [
        "block h-20 w-16 rounded-lg bg-primary",
        "block h-20 w-16 rounded-lg bg-success",
        "block h-20 w-16 rounded-lg bg-warning",
        "block h-20 w-16 rounded-lg bg-danger",
        "block h-20 w-16 rounded-lg bg-primary-soft",
      ];
      protected readonly title = "text-lg font-semibold text-ink";
      protected readonly hint = "mt-1 text-sm text-muted";
    }

    Contoh

    Promo pasar kuliner dengan emoji

    Jl. Braga, Bandung

    Weekend street food market

    40 stalls, Saturday and Sunday from 4 pm

    Jl. Braga, Bandung

    Weekend street food market

    40 stalls, Saturday and Sunday from 4 pm

    Jl. Braga, Bandung

    Weekend street food market

    40 stalls, Saturday and Sunday from 4 pm

    Jl. Braga, Bandung

    Weekend street food market

    40 stalls, Saturday and Sunday from 4 pm

    Jl. Braga, Bandung

    Weekend street food market

    40 stalls, Saturday and Sunday from 4 pm

    Bagian tim dengan inisial bertumpuk

    Meet the people behind Markas

    Rania, Dimas, Sekar, and Bayu

    Meet the people behind Markas

    Rania, Dimas, Sekar, and Bayu

    Meet the people behind Markas

    Rania, Dimas, Sekar, and Bayu

    Meet the people behind Markas

    Rania, Dimas, Sekar, and Bayu

    Meet the people behind Markas

    Rania, Dimas, Sekar, and Bayu

    Ajakan harga dengan autoplay

    Plans from Rp 49.000 a month

    Every plan includes all three frameworks

    Plans from Rp 49.000 a month

    Every plan includes all three frameworks

    Plans from Rp 49.000 a month

    Every plan includes all three frameworks

    Plans from Rp 49.000 a month

    Every plan includes all three frameworks

    Plans from Rp 49.000 a month

    Every plan includes all three frameworks

    Instalasi

    npx markasui@latest add image-trail

    Pemakaian

    <x-markas.image-trail variant="scale" :threshold="48" class="grid h-72 place-items-center rounded-xl bg-subtle">
        <x-slot:items>
            <img src="/img/sepatu-1.webp" alt="" class="w-20 rounded-lg" />
            <img src="/img/sepatu-2.webp" alt="" class="w-20 rounded-lg" />
            <img src="/img/sepatu-3.webp" alt="" class="w-20 rounded-lg" />
        </x-slot:items>
        <h2 class="text-2xl font-semibold">Sneakers musim baru</h2>
    </x-markas.image-trail>

    Butuh Alpine.js.

    import { ImageTrail } from "@/components/markas/ImageTrail";
    
    <ImageTrail
      variant="scale"
      threshold={48}
      className="grid h-72 place-items-center rounded-xl bg-subtle"
      items={
        <>
          <img src="/img/sepatu-1.webp" alt="" className="w-20 rounded-lg" />
          <img src="/img/sepatu-2.webp" alt="" className="w-20 rounded-lg" />
          <img src="/img/sepatu-3.webp" alt="" className="w-20 rounded-lg" />
        </>
      }
    >
      <h2 className="text-2xl font-semibold">Sneakers musim baru</h2>
    </ImageTrail>;
    <template>
      <ImageTrail
        variant="scale"
        :threshold="48"
        class="grid h-72 place-items-center rounded-xl bg-subtle"
      >
        <template #items>
          <img src="/img/sepatu-1.webp" alt="" class="w-20 rounded-lg" />
          <img src="/img/sepatu-2.webp" alt="" class="w-20 rounded-lg" />
          <img src="/img/sepatu-3.webp" alt="" class="w-20 rounded-lg" />
        </template>
        <h2 class="text-2xl font-semibold">Sneakers musim baru</h2>
      </ImageTrail>
    </template>
    <script lang="ts">
      import ImageTrail from "$lib/components/markas/ImageTrail.svelte";
    </script>
    
    <ImageTrail
      variant="scale"
      threshold={48}
      class="grid h-72 place-items-center rounded-xl bg-subtle"
    >
      {#snippet items()}
        <img src="/img/shoe-1.webp" alt="" class="w-20 rounded-lg" />
        <img src="/img/shoe-2.webp" alt="" class="w-20 rounded-lg" />
      {/snippet}
      <h2 class="text-2xl font-semibold">New season sneakers</h2>
    </ImageTrail>
    ---
    import ImageTrail from "@/components/markas/ImageTrail.astro";
    ---
    
    <ImageTrail
      variant="scale"
      threshold={48}
      class="grid h-72 place-items-center rounded-xl bg-subtle"
    >
      <Fragment slot="items">
        <img src="/img/shoe-1.webp" alt="" class="w-20 rounded-lg" />
        <img src="/img/shoe-2.webp" alt="" class="w-20 rounded-lg" />
      </Fragment>
      <h2 class="text-2xl font-semibold">New season sneakers</h2>
    </ImageTrail>

    Satu script kecil yang dibundel menjalankan setiap jejak lewat elemen markas-image-trail.

    import { Component } from "@angular/core";
    import { ImageTrail } from "./markas/image-trail.component";
    
    @Component({
      selector: "app-sneakers",
      imports: [ImageTrail],
      template: `
        <markas-image-trail
          variant="scale"
          [threshold]="48"
          class="grid h-72 place-items-center rounded-xl bg-subtle"
        >
          <ng-container items>
            <img src="/img/shoe-1.webp" alt="" class="w-20 rounded-lg" />
            <img src="/img/shoe-2.webp" alt="" class="w-20 rounded-lg" />
          </ng-container>
          <h2 class="text-2xl font-semibold">New season sneakers</h2>
        </markas-image-trail>
      `,
    })
    export class Sneakers {}
    • Elemen digandakan bergantian ke posisi kursor setiap threshold px. Paling banyak max salinan hidup sekaligus dan yang selesai dihapus, sehingga DOM tetap kecil.
    • variant: fade, scale, rotate (sudutnya mengikuti pola tetap, jadi setiap putaran terlihat sama), atau stack, tempat elemen menumpuk sampai kursor keluar.
    • autoplay menggambar jejak angka delapan selama area terlihat dan kursor di tempat lain. Berhenti saat area tergulir keluar atau tab disembunyikan.
    • Jejak berada di belakang konten dan bersifat aria-hidden. Dengan reduced motion tidak ada yang digambar. Atribut dan class jatuh ke area itu sendiri.

    Props

    NamaTipeDefaultKeterangan
    itemsReactNode / slot #itemsprimary dotElemen yang muncul di sepanjang jejak, digandakan bergantian. Gambar, kartu warna token, emoji, atau inisial.
    variant"fade" | "scale" | "rotate" | "stack""fade"fade: muncul lalu memudar. scale: membesar lalu mengecil. rotate: berputar masuk lalu jatuh sambil memudar. stack: menumpuk seperti foto sampai kursor keluar.
    thresholdnumber40Jarak dalam px yang ditempuh kursor sebelum elemen berikutnya muncul. Nilai besar membuat jejak lebih jarang.
    maxnumber12Jumlah elemen terbanyak di layar sekaligus. Yang paling lama dihapus lebih dulu, sehingga DOM tetap kecil.
    durationnumber800Umur satu elemen dalam ms. Pada stack, elemen masuk dalam 40% waktu ini lalu bertahan sampai kursor keluar.
    autoplaybooleanfalseMenggambar jejak angka delapan sendiri selama area terlihat, tab aktif, dan kursor di tempat lain. Berguna di layar sentuh.
    children / slotReactNode / slot-Konten di atas jejak. Atur tata letaknya dengan class sendiri pada komponen (grid, tinggi, padding).

    Aksesibilitas

    • Elemen jejak adalah salinan di dalam lapisan aria-hidden yang tidak menangkap pointer; elemen sumber ada di elemen hidden, jadi pembaca layar hanya membaca konten.
    • Jejak berada di belakang konten, sehingga teks dan tombol tetap terbaca dan bisa diklik.
    • Dengan reduced motion tidak ada jejak yang digambar dan autoplay tetap mati.

    Komponen terkait

    Komponen markasui lain dengan class yang sama di setiap framework.