Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Dock

    Dock ala macOS. Ikon membesar halus mengikuti kursor atau fokus, label muncul di atas, item terbuka bertitik, dan memantul saat dibuka.

    Inbox

    3 new messages from the design team

    Inbox

    3 new messages from the design team

    Inbox

    3 new messages from the design team

    Inbox

    3 new messages from the design team

    Inbox

    3 new messages from the design team

    @php
        $items = [
            ['label' => 'Files', 'icon' => 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z', 'active' => true],
            ['label' => 'Mail', 'icon' => 'M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6', 'active' => true],
            ['label' => 'Calendar', 'icon' => 'M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4'],
            ['label' => 'Music', 'icon' => 'M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z', 'active' => true],
            ['label' => 'Photos', 'icon' => 'M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01'],
            ['label' => 'Settings', 'icon' => 'M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4'],
            ['separator' => true],
            ['label' => 'Trash', 'icon' => 'M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3'],
        ];
    @endphp
    
    <div class="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4">
        <div class="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay">
            <div class="flex gap-1.5 border-b border-line px-3 py-2.5">
                <span class="size-2.5 rounded-full bg-line"></span>
                <span class="size-2.5 rounded-full bg-line"></span>
                <span class="size-2.5 rounded-full bg-line"></span>
            </div>
            <p class="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
            <p class="px-4 pt-1 text-sm text-muted">3 new messages from the design team</p>
        </div>
        <x-markas.dock :items="$items" />
    </div>
    import { Dock } from "@/components/markas/Dock";
    
    const items = [
      {
        label: "Files",
        icon: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
        active: true,
      },
      {
        label: "Mail",
        icon: "M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6",
        active: true,
      },
      {
        label: "Calendar",
        icon: "M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4",
      },
      {
        label: "Music",
        icon: "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
        active: true,
      },
      {
        label: "Photos",
        icon: "M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01",
      },
      {
        label: "Settings",
        icon: "M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4",
      },
      { separator: true },
      {
        label: "Trash",
        icon: "M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3",
      },
    ];
    
    export default function DockExample() {
      return (
        <div className="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4">
          <div className="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay">
            <div className="flex gap-1.5 border-b border-line px-3 py-2.5">
              <span className="size-2.5 rounded-full bg-line"></span>
              <span className="size-2.5 rounded-full bg-line"></span>
              <span className="size-2.5 rounded-full bg-line"></span>
            </div>
            <p className="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
            <p className="px-4 pt-1 text-sm text-muted">
              3 new messages from the design team
            </p>
          </div>
          <Dock items={items} />
        </div>
      );
    }
    <script setup lang="ts">
    import Dock from "@/components/markas/Dock.vue";
    
    const items = [
      {
        label: "Files",
        icon: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
        active: true,
      },
      {
        label: "Mail",
        icon: "M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6",
        active: true,
      },
      {
        label: "Calendar",
        icon: "M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4",
      },
      {
        label: "Music",
        icon: "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
        active: true,
      },
      {
        label: "Photos",
        icon: "M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01",
      },
      {
        label: "Settings",
        icon: "M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4",
      },
      { separator: true },
      {
        label: "Trash",
        icon: "M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3",
      },
    ];
    </script>
    
    <template>
      <div
        class="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4"
      >
        <div
          class="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay"
        >
          <div class="flex gap-1.5 border-b border-line px-3 py-2.5">
            <span class="size-2.5 rounded-full bg-line"></span
            ><span class="size-2.5 rounded-full bg-line"></span
            ><span class="size-2.5 rounded-full bg-line"></span>
          </div>
          <p class="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
          <p class="px-4 pt-1 text-sm text-muted">
            3 new messages from the design team
          </p>
        </div>
        <Dock :items="items" />
      </div>
    </template>
    <script lang="ts">
      import Dock, { type DockItem } from "$lib/components/markas/Dock.svelte";
    
      const items: DockItem[] = [
        {
          label: "Files",
          icon: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
          active: true,
        },
        {
          label: "Mail",
          icon: "M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6",
          active: true,
        },
        {
          label: "Calendar",
          icon: "M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4",
        },
        {
          label: "Music",
          icon: "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
          active: true,
        },
        {
          label: "Photos",
          icon: "M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01",
        },
        {
          label: "Settings",
          icon: "M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4",
        },
        { separator: true },
        {
          label: "Trash",
          icon: "M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3",
        },
      ];
    </script>
    
    <div
      class="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4"
    >
      <div
        class="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay"
      >
        <div class="flex gap-1.5 border-b border-line px-3 py-2.5">
          <span class="size-2.5 rounded-full bg-line"></span>
          <span class="size-2.5 rounded-full bg-line"></span>
          <span class="size-2.5 rounded-full bg-line"></span>
        </div>
        <p class="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
        <p class="px-4 pt-1 text-sm text-muted">
          3 new messages from the design team
        </p>
      </div>
      <Dock {items} />
    </div>
    ---
    import Dock, { type DockItem } from "@/components/markas/Dock.astro";
    
    const items: DockItem[] = [
      {
        label: "Files",
        icon: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
        active: true,
      },
      {
        label: "Mail",
        icon: "M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6",
        active: true,
      },
      {
        label: "Calendar",
        icon: "M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4",
      },
      {
        label: "Music",
        icon: "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
        active: true,
      },
      {
        label: "Photos",
        icon: "M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01",
      },
      {
        label: "Settings",
        icon: "M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4",
      },
      { separator: true },
      {
        label: "Trash",
        icon: "M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3",
      },
    ];
    ---
    
    <div
      class="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4"
    >
      <div
        class="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay"
      >
        <div class="flex gap-1.5 border-b border-line px-3 py-2.5">
          <span class="size-2.5 rounded-full bg-line"></span>
          <span class="size-2.5 rounded-full bg-line"></span>
          <span class="size-2.5 rounded-full bg-line"></span>
        </div>
        <p class="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
        <p class="px-4 pt-1 text-sm text-muted">
          3 new messages from the design team
        </p>
      </div>
      <Dock items={items} />
    </div>
    import { Component } from "@angular/core";
    import { Dock, type DockItem } from "./markas/dock.component";
    
    @Component({
      selector: "markas-example",
      imports: [Dock],
      template: `
        <div
          class="relative grid h-[280px] place-items-end justify-center overflow-hidden rounded-xl border border-line bg-subtle px-4 pb-4"
        >
          <div
            class="absolute inset-x-10 top-8 h-36 rounded-lg border border-line bg-surface shadow-overlay"
          >
            <div class="flex gap-1.5 border-b border-line px-3 py-2.5">
              <span class="size-2.5 rounded-full bg-line"></span>
              <span class="size-2.5 rounded-full bg-line"></span>
              <span class="size-2.5 rounded-full bg-line"></span>
            </div>
            <p class="px-4 pt-4 text-sm font-medium text-ink">Inbox</p>
            <p class="px-4 pt-1 text-sm text-muted">
              3 new messages from the design team
            </p>
          </div>
          <markas-dock [items]="items" />
        </div>
      `,
    })
    export default class DockExample {
      protected readonly items: DockItem[] = [
        {
          label: "Files",
          icon: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",
          active: true,
        },
        {
          label: "Mail",
          icon: "M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6",
          active: true,
        },
        {
          label: "Calendar",
          icon: "M5 5h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 10h18M8 3v4M16 3v4",
        },
        {
          label: "Music",
          icon: "M9 18V5l12-2v13M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM21 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",
          active: true,
        },
        {
          label: "Photos",
          icon: "M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM4 16l5-5 4 4 3-3 4 4M15 8h.01",
        },
        {
          label: "Settings",
          icon: "M4 6h9M17 6h3M4 12h3M11 12h9M4 18h11M19 18h1M15 4v4M9 10v4M17 16v4",
        },
        { separator: true },
        {
          label: "Trash",
          icon: "M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3",
        },
      ];
    }

    Contoh

    Link situs

    Alat editor

    Pembesaran kuat

    Instalasi

    npx markasui@latest add dock

    Pemakaian

    <x-markas.dock
        dock-label="Dok aplikasi"
        :magnification="1.6"
        x-on:select="bukaAplikasi($event.detail)"
        :items="[
            ['label' => 'Berkas', 'value' => 'files', 'icon' => 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z', 'active' => true],
            ['label' => 'Surel', 'value' => 'mail', 'icon' => 'M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM3 7l9 6 9-6'],
            ['separator' => true],
            ['label' => 'Blog', 'href' => '/blog', 'icon' => 'M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'],
        ]"
    />
    import { Dock } from "@/components/markas/Dock";
    
    <Dock
      dockLabel="Dok aplikasi"
      items={[
        { label: "Berkas", value: "files", icon: folderPath, active: true },
        { label: "Surel", value: "mail", icon: mailPath },
        { separator: true },
        { label: "Blog", href: "/blog", icon: penPath },
      ]}
      onItemSelect={bukaAplikasi}
    />;
    <script setup lang="ts">
    import Dock from "@/components/markas/Dock.vue";
    </script>
    
    <template>
      <Dock
        :items="items"
        dock-label="Dok aplikasi"
        :magnification="1.6"
        @select="bukaAplikasi"
      />
    </template>
    <script lang="ts">
      import Dock, { type DockItem } from "$lib/components/markas/Dock.svelte";
    
      const items: DockItem[] = [
        { label: "Files", value: "files", icon: folderPath, active: true },
        { label: "Mail", value: "mail", icon: mailPath },
        { separator: true },
        { label: "Blog", href: "/blog", icon: penPath },
      ];
    </script>
    
    <Dock {items} onItemSelect={openApp} />
    ---
    import Dock, { type DockItem } from "@/components/markas/Dock.astro";
    
    const items: DockItem[] = [
      { label: "Files", value: "files", icon: folderPath, active: true },
      { separator: true },
      { label: "Blog", href: "/blog", icon: penPath },
    ];
    ---
    
    <Dock items={items} />

    Custom element kecil memperbesar item dan memindahkan tab stop. Menekan item mengirim event markas-select yang menggelembung dengan value-nya sebagai detail.

    import { Component } from "@angular/core";
    import { Dock, type DockItem } from "./markas/dock.component";
    
    @Component({
      selector: "app-dock",
      imports: [Dock],
      template: `<markas-dock [items]="items" (itemSelect)="openApp($event)" />`,
    })
    export class AppDock {
      items: DockItem[] = [
        { label: "Files", value: "files", icon: "M3 7h18v12H3z", active: true },
        { separator: true },
        { label: "Blog", href: "/blog", icon: "M12 20h9" },
      ];
      openApp(value: string) {}
    }
    • Item membesar dengan kurva kosinus dalam jarak 140px di sekitar kursor, dan di sekitar item yang difokus saat memakai keyboard.
    • Dock adalah toolbar dengan roving tabindex: Tab masuk sekali, panah berpindah antar item.
    • Menekan item memutar pantulan singkat dan memicu select. Item dengan href berpindah halaman seperti link biasa.
    • Reduced motion menjaga setiap item di ukuran dasar dan melewati pantulan.
    • Dock tidak pernah lebih lebar dari wadahnya. Di wadah yang sempit, item mengecil merata supaya semuanya tetap terlihat.

    Props

    NamaTipeDefaultKeterangan
    items({ label: string; icon: string; value?: string; href?: string; active?: boolean } | { separator: true })[][]Item dock berurutan. icon adalah atribut d path SVG 24x24 bergaris. { separator: true } menggambar pemisah. Item dengan href menjadi link.
    magnificationnumber1.6Seberapa besar item di bawah kursor atau fokus membesar. Tetangga dalam 140px membesar lebih sedikit. 1 mematikannya.
    onItemSelect / @select / x-on:select(value: string) => void-Dipicu saat item ditekan, dengan value atau label-nya. Blade mengirim event DOM select dengan value sebagai detail.
    dockLabelstringDockNama aksesibel toolbar.
    (itemSelect)output<string>-Khusus Angular. Memancarkan value (atau label) item yang ditekan. Svelte memakai onItemSelect seperti React.
    markas-selectCustomEvent<string>-Khusus Astro. Event menggelembung dengan value item yang ditekan sebagai detail.

    Aksesibilitas

    • Dock adalah toolbar bernama dockLabel. Hanya satu item di urutan tab, Panah Kiri, Panah Kanan, Home, dan End berpindah antar item (roving tabindex).
    • Label di dalam setiap item menjadi nama aksesibelnya dan tampil sebagai tooltip saat hover dan fokus keyboard.
    • Item bertitik memakai aria-current="true". Pemisah memakai role="separator".
    • Dengan reduced motion, pembesaran dan pantulan mati, item tetap di ukuran dasar.

    Komponen terkait

    Komponen markasui lain dengan class yang sama di setiap framework.