Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Image Trail

    Area where images, cards, or emoji pop up along the pointer path and fade, scale, spin, or pile up. Can draw its own trail while on screen.

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

    Examples

    Food market promo with 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

    Team section with stacking initials

    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

    Pricing call to action with 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

    Installation

    npx markasui@latest add image-trail

    Usage

    <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/shoe-1.webp" alt="" class="w-20 rounded-lg" />
            <img src="/img/shoe-2.webp" alt="" class="w-20 rounded-lg" />
            <img src="/img/shoe-3.webp" alt="" class="w-20 rounded-lg" />
        </x-slot:items>
        <h2 class="text-2xl font-semibold">New season sneakers</h2>
    </x-markas.image-trail>

    Needs 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/shoe-1.webp" alt="" className="w-20 rounded-lg" />
          <img src="/img/shoe-2.webp" alt="" className="w-20 rounded-lg" />
          <img src="/img/shoe-3.webp" alt="" className="w-20 rounded-lg" />
        </>
      }
    >
      <h2 className="text-2xl font-semibold">New season sneakers</h2>
    </ImageTrail>;
    <template>
      <ImageTrail
        variant="scale"
        :threshold="48"
        class="grid h-72 place-items-center rounded-xl bg-subtle"
      >
        <template #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" />
          <img src="/img/shoe-3.webp" alt="" class="w-20 rounded-lg" />
        </template>
        <h2 class="text-2xl font-semibold">New season sneakers</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>

    A small bundled script runs each trail through the markas-image-trail element.

    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 {}
    • Items are cloned in order to the pointer every threshold px. At most max clones live at once and finished ones are removed, so the DOM stays small.
    • variant: fade, scale, rotate (the angle follows a fixed pattern, so every run looks the same), or stack, where items pile up until the pointer leaves.
    • autoplay draws a figure-eight trail while the area is on screen and the pointer is elsewhere. It pauses when the area scrolls away or the tab is hidden.
    • The trail sits behind the content and is aria-hidden. With reduced motion nothing is drawn. Attributes and class go to the area itself.

    Props

    NameTypeDefaultDescription
    itemsReactNode / slot #itemsprimary dotElements that appear along the trail, cloned one after another. Images, token color cards, emoji, or initials.
    variant"fade" | "scale" | "rotate" | "stack""fade"fade: appear and fade out. scale: pop in and shrink away. rotate: spin in and drop while fading. stack: pile up like photos until the pointer leaves.
    thresholdnumber40Distance in px the pointer travels before the next item appears. Larger values give a sparser trail.
    maxnumber12Most items on screen at once. The oldest is removed first, so the DOM stays small.
    durationnumber800Life of one item in ms. In stack, items enter in 40% of this and stay until the pointer leaves.
    autoplaybooleanfalseDraws a figure-eight trail on its own while the area is on screen, the tab is visible, and the pointer is elsewhere. Handy on touch screens.
    children / slotReactNode / slot-Content shown above the trail. Lay it out with your own classes on the component (grid, height, padding).

    Accessibility

    • Trail items are clones inside an aria-hidden layer that never catches the pointer; the source items sit in a hidden element, so screen readers only read the content.
    • The trail sits behind the content, so text and buttons stay readable and clickable.
    • With reduced motion no trail is drawn and autoplay stays off.

    Related components

    More markasui components with the same classes in every framework.