Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Avatar Group

    Tumpukan avatar yang mengembang saat hover, menampilkan nama di tooltip, dan meringkas sisa orang menjadi chip +N.

    Dewi Lestari BS SA JC 3 more
    7 people on this project
    Dewi LestariBSSAJC3 more
    7 people on this project
    Dewi LestariBSSAJC3 more
    7 people on this project
    Dewi LestariBSSAJC 3 more
    7 people on this project
    Dewi LestariBSSAJC3 more
    7 people on this project
    @php
        $team = [
            ['name' => 'Dewi Lestari', 'src' => "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E"],
            ['name' => 'Budi Santoso'],
            ['name' => 'Siti Aminah'],
            ['name' => 'John Carter'],
            ['name' => 'Maya Putri'],
            ['name' => 'Rizal Hakim'],
            ['name' => 'Ana Lim'],
        ];
    @endphp
    
    <div class="flex items-center gap-3 pt-8">
        <x-markas.avatar-group :items="$team" group-label="Project members" />
        <span class="text-sm text-muted">7 people on this project</span>
    </div>
    import { AvatarGroup } from "@/components/markas/AvatarGroup";
    
    const photo =
      "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E";
    
    const team = [
      { name: "Dewi Lestari", src: photo },
      { name: "Budi Santoso" },
      { name: "Siti Aminah" },
      { name: "John Carter" },
      { name: "Maya Putri" },
      { name: "Rizal Hakim" },
      { name: "Ana Lim" },
    ];
    
    export default function AvatarGroupExample() {
      return (
        <div className="flex items-center gap-3 pt-8">
          <AvatarGroup items={team} groupLabel="Project members" />
          <span className="text-sm text-muted">7 people on this project</span>
        </div>
      );
    }
    <script setup lang="ts">
    import AvatarGroup from "@/components/markas/AvatarGroup.vue";
    
    const photo =
      "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E";
    
    const team = [
      { name: "Dewi Lestari", src: photo },
      { name: "Budi Santoso" },
      { name: "Siti Aminah" },
      { name: "John Carter" },
      { name: "Maya Putri" },
      { name: "Rizal Hakim" },
      { name: "Ana Lim" },
    ];
    </script>
    
    <template>
      <div class="flex items-center gap-3 pt-8">
        <AvatarGroup :items="team" group-label="Project members" />
        <span class="text-sm text-muted">7 people on this project</span>
      </div>
    </template>
    <script lang="ts">
      import AvatarGroup from "$lib/components/markas/AvatarGroup.svelte";
    
      const photo =
        "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E";
    
      const team = [
        { name: "Dewi Lestari", src: photo },
        { name: "Budi Santoso" },
        { name: "Siti Aminah" },
        { name: "John Carter" },
        { name: "Maya Putri" },
        { name: "Rizal Hakim" },
        { name: "Ana Lim" },
      ];
    </script>
    
    <div class="flex items-center gap-3 pt-8">
      <AvatarGroup items={team} groupLabel="Project members" />
      <span class="text-sm text-muted">7 people on this project</span>
    </div>
    ---
    import AvatarGroup from "@/components/markas/AvatarGroup.astro";
    
    const photo =
      "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E";
    
    const team = [
      { name: "Dewi Lestari", src: photo },
      { name: "Budi Santoso" },
      { name: "Siti Aminah" },
      { name: "John Carter" },
      { name: "Maya Putri" },
      { name: "Rizal Hakim" },
      { name: "Ana Lim" },
    ];
    ---
    
    <div class="flex items-center gap-3 pt-8">
      <AvatarGroup items={team} groupLabel="Project members" />
      <span class="text-sm text-muted">7 people on this project</span>
    </div>
    import { Component } from "@angular/core";
    import { AvatarGroup } from "./markas/avatar-group.component";
    
    const photo =
      "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='rgb(46 107 58)'/%3E%3Ccircle cx='24' cy='19' r='8' fill='rgb(231 239 229)'/%3E%3Cpath d='M8 46c1-9 8-15 16-15s15 6 16 15z' fill='rgb(231 239 229)'/%3E%3C/svg%3E";
    
    @Component({
      selector: "markas-example",
      imports: [AvatarGroup],
      template: `
        <div class="flex items-center gap-3 pt-8">
          <div
            markas-avatar-group
            [items]="team"
            groupLabel="Project members"
          ></div>
          <span class="text-sm text-muted">7 people on this project</span>
        </div>
      `,
    })
    export default class AvatarGroupExample {
      protected readonly team = [
        { name: "Dewi Lestari", src: photo },
        { name: "Budi Santoso" },
        { name: "Siti Aminah" },
        { name: "John Carter" },
        { name: "Maya Putri" },
        { name: "Rizal Hakim" },
        { name: "Ana Lim" },
      ];
    }

    Contoh

    Ukuran

    DL BS SA 2 more
    DL BS SA 2 more
    DL BS SA 2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA 2 more
    DLBSSA 2 more
    DLBSSA 2 more
    DLBSSA2 more
    DLBSSA2 more
    DLBSSA2 more

    Dalam kartu proyek

    Website redesign

    Due Friday, 14 of 20 tasks done

    On track
    Dewi Lestari BS SA 2 more
    70%

    Website redesign

    Due Friday, 14 of 20 tasks done

    On track
    Dewi LestariBSSA2 more
    70%

    Website redesign

    Due Friday, 14 of 20 tasks done

    On track
    Dewi LestariBSSA2 more
    70%

    Website redesign

    Due Friday, 14 of 20 tasks done

    On track
    Dewi LestariBSSA 2 more
    70%

    Website redesign

    Due Friday, 14 of 20 tasks done

    On track
    Dewi LestariBSSA2 more
    70%

    Disukai oleh

    MP RH AL 3 more

    Maya Putri and 5 others liked this

    MPRHAL3 more

    Maya Putri and 5 others liked this

    MPRHAL3 more

    Maya Putri and 5 others liked this

    MPRHAL 3 more

    Maya Putri and 5 others liked this

    MPRHAL3 more

    Maya Putri and 5 others liked this

    Instalasi

    npx markasui@latest add avatar-group

    Pemakaian

    <x-markas.avatar-group
        :items="[
            ['name' => 'Dewi Lestari', 'src' => '/avatars/dewi.jpg'],
            ['name' => 'Budi Santoso'],
            ['name' => 'Siti Aminah'],
            ['name' => 'John Carter'],
            ['name' => 'Maya Putri'],
        ]"
        :max="3"
        group-label="Anggota proyek"
        more-label="{count} lainnya"
    />
    import { AvatarGroup } from "@/components/markas/AvatarGroup";
    
    <AvatarGroup
      items={[
        { name: "Dewi Lestari", src: "/avatars/dewi.jpg" },
        { name: "Budi Santoso" },
        { name: "Siti Aminah" },
        { name: "John Carter" },
        { name: "Maya Putri" },
      ]}
      max={3}
      groupLabel="Anggota proyek"
      moreLabel="{count} lainnya"
    />;
    <template>
      <AvatarGroup
        :items="team"
        :max="3"
        group-label="Anggota proyek"
        more-label="{count} lainnya"
      />
    </template>
    <script lang="ts">
      import AvatarGroup from "$lib/components/markas/AvatarGroup.svelte";
    
      const team = [
        { name: "Dewi Lestari", src: "/dewi.jpg" },
        { name: "Budi Santoso" },
      ];
    </script>
    
    <AvatarGroup items={team} max={3} groupLabel="Project members" />
    ---
    import AvatarGroup from "@/components/markas/AvatarGroup.astro";
    
    const team = [{ name: "Dewi Lestari", src: "/dewi.jpg" }, { name: "Budi Santoso" }];
    ---
    
    <AvatarGroup items={team} max={3} groupLabel="Project members" />
    import { Component } from "@angular/core";
    import { AvatarGroup } from "./markas/avatar-group.component";
    
    @Component({
      selector: "app-members",
      imports: [AvatarGroup],
      template: `
        <div
          markas-avatar-group
          [items]="team"
          [max]="3"
          groupLabel="Project members"
        ></div>
      `,
    })
    export class Members {
      team = [{ name: "Dewi Lestari", src: "/dewi.jpg" }, { name: "Budi Santoso" }];
    }
    • Tanpa JavaScript. Versi Blade tidak butuh Alpine.js; efek hover murni CSS.
    • Orang setelah max diringkas menjadi chip +N. Tooltip-nya berisi nama mereka dan screen reader membaca moreLabel (“2 lainnya”).
    • Ring di antara avatar memakai warna canvas. Di atas kartu, isi class="[--avatar-ring:var(--color-surface)]".
    • Tooltip muncul di atas grup, jadi sisakan ruang di sana.

    Props

    NamaTipeDefaultKeterangan
    items{ name: string; src?: string }[][]Orang di dalam grup. Tanpa src, inisial name yang tampil.
    maxnumber4Jumlah avatar yang tampil sebelum sisanya diringkas menjadi chip +N.
    size'sm' | 'md' | 'lg'mdUkuran avatar 32, 40, atau 48 piksel. Tumpukan ikut menyesuaikan.
    groupLabelstringMembersNama aksesibel grup, misalnya "Anggota proyek".
    moreLabelstring{count} moreTeks tersembunyi di chip +N untuk screen reader. {count} diganti jumlah orang yang tersembunyi.

    Aksesibilitas

    • Tumpukan berupa group dengan nama aksesibel dari groupLabel.
    • Setiap avatar adalah gambar bernama orang itu (alt atau role img dengan aria-label), jadi screen reader tidak butuh tooltip.
    • Tooltip dan +N yang terlihat memakai aria-hidden; chip membacakan moreLabel.
    • Dengan reduced motion, efek mengembang dan terangkat terjadi seketika tanpa transisi.

    Komponen terkait

    Komponen animasi lain dengan class yang sama di setiap framework.