Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Carousel

    Deretan slide berbasis CSS scroll snap dengan tombol sebelumnya dan berikutnya, titik opsional, dan navigasi panah. Tanpa autoplay.

    Plan your week

    Drag tasks onto the calendar to block focus time.

    Share with your team

    Invite teammates and assign tasks in one click.

    Track progress

    See what shipped this week on a single dashboard.

    Plan your week

    Drag tasks onto the calendar to block focus time.

    Share with your team

    Invite teammates and assign tasks in one click.

    Track progress

    See what shipped this week on a single dashboard.

    Plan your week

    Drag tasks onto the calendar to block focus time.

    Share with your team

    Invite teammates and assign tasks in one click.

    Track progress

    See what shipped this week on a single dashboard.

    @php
        $card = 'flex h-40 flex-col justify-end rounded-xl bg-subtle p-5';
        $title = 'text-sm font-medium text-ink';
        $text = 'mt-1 text-sm text-muted';
    @endphp
    
    <x-markas.carousel label="Product tour" show-dots>
        <x-slot:plan>
            <div class="{{ $card }}">
                <p class="{{ $title }}">Plan your week</p>
                <p class="{{ $text }}">Drag tasks onto the calendar to block focus time.</p>
            </div>
        </x-slot:plan>
        <x-slot:share>
            <div class="{{ $card }}">
                <p class="{{ $title }}">Share with your team</p>
                <p class="{{ $text }}">Invite teammates and assign tasks in one click.</p>
            </div>
        </x-slot:share>
        <x-slot:track>
            <div class="{{ $card }}">
                <p class="{{ $title }}">Track progress</p>
                <p class="{{ $text }}">See what shipped this week on a single dashboard.</p>
            </div>
        </x-slot:track>
    </x-markas.carousel>
    import { Carousel } from "@/components/markas/Carousel";
    
    const card = "flex h-40 flex-col justify-end rounded-xl bg-subtle p-5";
    const title = "text-sm font-medium text-ink";
    const text = "mt-1 text-sm text-muted";
    
    export default function CarouselExample() {
      return (
        <Carousel label="Product tour" showDots>
          <div className={card}>
            <p className={title}>Plan your week</p>
            <p className={text}>
              Drag tasks onto the calendar to block focus time.
            </p>
          </div>
          <div className={card}>
            <p className={title}>Share with your team</p>
            <p className={text}>Invite teammates and assign tasks in one click.</p>
          </div>
          <div className={card}>
            <p className={title}>Track progress</p>
            <p className={text}>
              See what shipped this week on a single dashboard.
            </p>
          </div>
        </Carousel>
      );
    }
    <script setup lang="ts">
    import Carousel from "@/components/markas/Carousel.vue";
    
    const card = "flex h-40 flex-col justify-end rounded-xl bg-subtle p-5";
    const title = "text-sm font-medium text-ink";
    const text = "mt-1 text-sm text-muted";
    </script>
    
    <template>
      <Carousel label="Product tour" show-dots>
        <div :class="card">
          <p :class="title">Plan your week</p>
          <p :class="text">Drag tasks onto the calendar to block focus time.</p>
        </div>
        <div :class="card">
          <p :class="title">Share with your team</p>
          <p :class="text">Invite teammates and assign tasks in one click.</p>
        </div>
        <div :class="card">
          <p :class="title">Track progress</p>
          <p :class="text">See what shipped this week on a single dashboard.</p>
        </div>
      </Carousel>
    </template>
    <script lang="ts">
      import Carousel from "$lib/components/markas/Carousel.svelte";
    
      const card = "flex h-40 flex-col justify-end rounded-xl bg-subtle p-5";
      const title = "text-sm font-medium text-ink";
      const text = "mt-1 text-sm text-muted";
    
      const slides = [
        {
          title: "Plan your week",
          text: "Drag tasks onto the calendar to block focus time.",
        },
        {
          title: "Share with your team",
          text: "Invite teammates and assign tasks in one click.",
        },
        {
          title: "Track progress",
          text: "See what shipped this week on a single dashboard.",
        },
      ];
    </script>
    
    <Carousel label="Product tour" showDots items={slides}>
      {#snippet slide(item)}
        <div class={card}>
          <p class={title}>{item.title}</p>
          <p class={text}>{item.text}</p>
        </div>
      {/snippet}
    </Carousel>
    ---
    import Carousel from "@/components/markas/Carousel.astro";
    
    const card = "flex h-40 flex-col justify-end rounded-xl bg-subtle p-5";
    const title = "text-sm font-medium text-ink";
    const text = "mt-1 text-sm text-muted";
    
    const slides = [
      {
        title: "Plan your week",
        text: "Drag tasks onto the calendar to block focus time.",
      },
      {
        title: "Share with your team",
        text: "Invite teammates and assign tasks in one click.",
      },
      {
        title: "Track progress",
        text: "See what shipped this week on a single dashboard.",
      },
    ];
    ---
    
    <Carousel label="Product tour" showDots items={slides}>
      {
        (item: (typeof slides)[number]) => (
          <div class={card}>
            <p class={title}>{item.title}</p>
            <p class={text}>{item.text}</p>
          </div>
        )
      }
    </Carousel>
    import { Component } from "@angular/core";
    import { Carousel } from "./markas/carousel.component";
    
    @Component({
      selector: "markas-example",
      imports: [Carousel],
      template: `
        <markas-carousel label="Product tour" showDots [items]="slides">
          <ng-template let-item>
            <div [class]="card">
              <p [class]="title">{{ item.title }}</p>
              <p [class]="text">{{ item.text }}</p>
            </div>
          </ng-template>
        </markas-carousel>
      `,
    })
    export default class CarouselExample {
      protected readonly card =
        "flex h-40 flex-col justify-end rounded-xl bg-subtle p-5";
      protected readonly title = "text-sm font-medium text-ink";
      protected readonly text = "mt-1 text-sm text-muted";
      protected readonly slides = [
        {
          title: "Plan your week",
          text: "Drag tasks onto the calendar to block focus time.",
        },
        {
          title: "Share with your team",
          text: "Invite teammates and assign tasks in one click.",
        },
        {
          title: "Track progress",
          text: "See what shipped this week on a single dashboard.",
        },
      ];
    }

    Contoh

    Beberapa sekaligus

    Desk lamp

    $48

    Notebook set

    $18

    Wool throw

    $64

    Ceramic mug

    $14

    Desk lamp

    $48

    Notebook set

    $18

    Wool throw

    $64

    Ceramic mug

    $14

    Desk lamp

    $48

    Notebook set

    $18

    Wool throw

    $64

    Ceramic mug

    $14

    Testimoni

    We moved our admin panel to MarkasUI in a weekend. Design reviews are half as long now.
    Dewi LestariHead of Product, Jakarta
    One set of tokens for Blade and Vue replaced three style guides and a lot of pixel nudging.
    Budi SantosoEngineering Manager, Bandung
    Simple enough for client handoffs, flexible enough for every brand I work with.
    Siti AminahFreelance developer, Yogyakarta
    We moved our admin panel to MarkasUI in a weekend. Design reviews are half as long now.
    Dewi LestariHead of Product, Jakarta
    One set of tokens for Blade and Vue replaced three style guides and a lot of pixel nudging.
    Budi SantosoEngineering Manager, Bandung
    Simple enough for client handoffs, flexible enough for every brand I work with.
    Siti AminahFreelance developer, Yogyakarta
    We moved our admin panel to MarkasUI in a weekend. Design reviews are half as long now.
    Dewi Lestari Head of Product, Jakarta
    One set of tokens for Blade and Vue replaced three style guides and a lot of pixel nudging.
    Budi Santoso Engineering Manager, Bandung
    Simple enough for client handoffs, flexible enough for every brand I work with.
    Siti Aminah Freelance developer, Yogyakarta

    Galeri foto

    Living room, photo 1 of 4

    Kitchen, photo 2 of 4

    Bedroom, photo 3 of 4

    Garden, photo 4 of 4

    Living room, photo 1 of 4

    Kitchen, photo 2 of 4

    Bedroom, photo 3 of 4

    Garden, photo 4 of 4

    Living room, photo 1 of 4

    Kitchen, photo 2 of 4

    Bedroom, photo 3 of 4

    Garden, photo 4 of 4

    Instalasi

    npx markasui@latest add carousel

    Pemakaian

    <x-markas.carousel
        label="Tur produk"
        show-dots
        previous-label="Slide sebelumnya"
        next-label="Slide berikutnya"
        slide-label="{index} dari {total}"
        dot-label="Ke slide {index}"
    >
        <x-slot:rencana>
            <div class="h-40 rounded-xl bg-subtle p-5">Rencanakan minggu Anda</div>
        </x-slot:rencana>
        <x-slot:bagikan>
            <div class="h-40 rounded-xl bg-subtle p-5">Bagikan ke tim</div>
        </x-slot:bagikan>
    </x-markas.carousel>

    Butuh Alpine.js. Setiap named slot menjadi satu slide sesuai urutan penulisan. Untuk daftar, pakai <x-slot :name="'slide-'.$index"> di dalam @foreach.

    import { Carousel } from "@/components/markas/Carousel";
    
    <Carousel
      label="Tur produk"
      showDots
      previousLabel="Slide sebelumnya"
      nextLabel="Slide berikutnya"
      slideLabel="{index} dari {total}"
      dotLabel="Ke slide {index}"
    >
      <div className="h-40 rounded-xl bg-subtle p-5">Rencanakan minggu Anda</div>
      <div className="h-40 rounded-xl bg-subtle p-5">Bagikan ke tim</div>
    </Carousel>;
    <template>
      <Carousel
        label="Tur produk"
        show-dots
        previous-label="Slide sebelumnya"
        next-label="Slide berikutnya"
        slide-label="{index} dari {total}"
        dot-label="Ke slide {index}"
      >
        <div class="h-40 rounded-xl bg-subtle p-5">Rencanakan minggu Anda</div>
        <div class="h-40 rounded-xl bg-subtle p-5">Bagikan ke tim</div>
      </Carousel>
    </template>
    <script lang="ts">
      import Carousel from "$lib/components/markas/Carousel.svelte";
    
      const slides = ["Plan your week", "Share with your team", "Track progress"];
    </script>
    
    <Carousel label="Product tour" showDots items={slides}>
      {#snippet slide(title, index)}
        <div class="h-40 rounded-xl bg-subtle p-5">{index + 1}. {title}</div>
      {/snippet}
    </Carousel>

    Svelte, Astro, dan Angular menerima slide sebagai items dan merender tiap item lewat snippet, function child, atau ng-template. Svelte membaca {index} di atribut biasa sebagai ekspresi, jadi tulis template label di dalam kurung kurawal: slideLabel={"Slide {index} dari {total}"}.

    ---
    import Carousel from "@/components/markas/Carousel.astro";
    
    const slides = ["Plan your week", "Share with your team", "Track progress"];
    ---
    
    <Carousel label="Product tour" showDots items={slides}>
      {
        (title: string, index: number) => (
          <div class="h-40 rounded-xl bg-subtle p-5">{index + 1}. {title}</div>
        )
      }
    </Carousel>

    Setiap carousel adalah custom element kecil, jadi tetap jalan setelah view transition.

    import { Component } from "@angular/core";
    import { Carousel } from "./markas/carousel.component";
    
    @Component({
      selector: "app-example",
      imports: [Carousel],
      template: `
        <markas-carousel label="Product tour" showDots [items]="slides">
          <ng-template let-title let-index="index">
            <div class="h-40 rounded-xl bg-subtle p-5">
              {{ index + 1 }}. {{ title }}
            </div>
          </ng-template>
        </markas-carousel>
      `,
    })
    export class Example {
      slides = ["Plan your week", "Share with your team", "Track progress"];
    }
    • Slide digulir dengan CSS scroll snap, jadi swipe sentuh dan trackpad langsung berfungsi.
    • Pakai perView 2 atau 3 untuk menampilkan beberapa kartu sekaligus. Tombol tetap bergeser satu slide per tekan.
    • slideLabel dan dotLabel menerima placeholder {index} dan {total}.
    • Sengaja tanpa autoplay.

    Props

    NamaTipeDefaultKeterangan
    slidesBlade: named slots · React: children · Vue: default slot · Svelte, Astro, Angular: items-Setiap named slot (Blade) atau setiap elemen anak (React dan Vue) menjadi satu slide, sesuai urutan. Svelte, Astro, dan Angular merender satu slide per entri items.
    itemsT[]-Khusus Svelte, Astro, dan Angular. Data slide, dirender oleh snippet slide (Svelte), function child (Astro), atau ng-template dengan let-item dan let-index (Angular).
    labelstringCarouselNama aksesibel region carousel. Jelaskan isinya, misalnya Tur produk.
    perView1 | 2 | 31Jumlah slide yang terlihat sekaligus. Tombol tetap bergeser satu slide.
    showDotsbooleanfalseTampilkan satu titik per slide untuk melompat ke slide itu. Paling cocok dengan perView 1.
    previousLabelstringPrevious slideLabel aksesibel tombol sebelumnya. Isi "Slide sebelumnya" untuk situs berbahasa Indonesia.
    nextLabelstringNext slideLabel aksesibel tombol berikutnya. Isi "Slide berikutnya" untuk situs berbahasa Indonesia.
    slideLabelstring{index} of {total}Label aksesibel tiap slide. {index} dan {total} diganti angka, misalnya "{index} dari {total}".
    dotLabelstringGo to slide {index}Label aksesibel tiap titik. {index} dan {total} diganti angka, misalnya "Ke slide {index}".

    Aksesibilitas

    • Root adalah region dengan aria-roledescription=carousel dan prop label sebagai namanya.
    • Setiap slide adalah group dengan aria-roledescription=slide dan label seperti 2 of 4.
    • Panah kiri dan kanan bergeser satu slide selama fokus ada di dalam carousel, dan viewport gulirnya sendiri bisa difokus.
    • Tombol sebelumnya dan berikutnya adalah button native yang nonaktif di ujung, dan titik aktif punya aria-current=true.
    • Tidak ada yang bergerak sendiri, jadi tidak perlu kontrol jeda. Gulir langsung tanpa animasi saat reduced motion aktif.

    Komponen terkait

    Komponen data lain dengan class yang sama di setiap framework.