v0.0.2
Demos (demo panel, opens in a new tab)

Basic card

The basic container that groups content on a surface, together with a header, an actions area and a footer.

zb:card zubazar/ui · free (MIT)

Basic usage

Basic usage: view
BLADE

title and subtitle build the header, and the content goes in the default slot.

blade
<zb:card title="Kadıköy warehouse" subtitle="IST-04 · 148 orders">
    <p class="text-sm text-dim">112 orders shipped this month; 36 orders are waiting.</p>
</zb:card>
PropValues
titleCard title
subtitleShort description below the title

Header actions

Header actions: view
BLADE

The actions slot puts a badge, a small button or a dropdown to the right of the header.

blade
<zb:card title="Open tickets" subtitle="38 tickets">
    <zb:slot:actions>
        <zb:badge variant="success">Up to date</zb:badge>
        <zb:button size="sm" variant="ghost">All</zb:button>
    </zb:slot:actions>
    <p class="text-sm text-dim">12 tickets are awaiting a reply today; 3 tickets are resolved.</p>
</zb:card>
PropValues
actionsSlot; right of the header

Collapsing and closing

Collapsing and closing: view
BLADE

collapsible adds an arrow to the header that collapses the body, and closable adds a cross that hides the card.

blade
<div class="grid gap-4 md:grid-cols-2">
    <zb:card title="Shipping notes" collapsible>
        <p class="text-sm text-dim">Carriers are busy on the Anatolian side on Tuesdays; deliveries may be a day late.</p>
    </zb:card>

    <zb:card title="Announcement" closable>
        <p class="text-sm text-dim">The October sale starts on Monday, October 7. The support team should review the new return policy.</p>
    </zb:card>
</div>
PropValues
collapsibletrue | false
closabletrue | false

Without padding

Without padding: view
BLADE

:padding="false" removes the body's padding; for a list, use zb:list-group with flush.

blade
<zb:card title="Recent orders" :padding="false">
    <zb:list-group flush>
        <zb:list-group.item>Ayşe Yılmaz · Wireless headphones <span class="ms-auto text-xs text-muted">09:42</span></zb:list-group.item>
        <zb:list-group.item>Mehmet Kaya · Smart watch <span class="ms-auto text-xs text-muted">09:17</span></zb:list-group.item>
        <zb:list-group.item>Zeynep Arslan · Laptop bag <span class="ms-auto text-xs text-muted">08:55</span></zb:list-group.item>
    </zb:list-group>
</zb:card>
PropValues
paddingtrue | false

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
title—nullCard title
subtitle—nullDescription below the title
collapsiblebooleanfalseButton that collapses the body
closablebooleanfalseButton that hides the card
paddingbooleantruefalse: body without padding (tables, lists)
heading-levelnumber3The title's heading level (2–6), to fit the page's outline; card.header reads it too
card.header: title · subtitle—nullTitle and secondary line; without title, the slot is the title itself (icon, text, badge)
card.body: paddingbooleantruefalse: body without padding

Slots: actions (right of the header), footer (footer), default content (body) · Composed: zb:card.header (actions slot), zb:card.body, zb:card.footer

Advanced

4 examples

Composing from parts

Composing from parts: view
BLADE

If the header needs an icon, a badge or buttons, write the card with the zb:card.header, zb:card.body and zb:card.footer parts. If you give the header no title, its slot is the title itself.

blade
<zb:card collapsible>
    <zb:card.header subtitle="486 packages today · 3 carriers">
        <zb:icon name="truck" size="4" class="text-primary-ink" />
        Shipment tracking
        <zb:badge variant="success">Live</zb:badge>

        <zb:slot:actions>
            <zb:button size="sm" variant="white">
                <zb:icon name="arrow-path" size="4" /> Refresh
            </zb:button>
        </zb:slot:actions>
    </zb:card.header>

    <zb:card.body>
        <dl class="grid grid-cols-3 gap-4 text-sm">
            <div>
                <dt class="text-muted">Delivered</dt>
                <dd class="mt-1 text-lg font-semibold tabular-nums text-ink">312</dd>
            </div>
            <div>
                <dt class="text-muted">In transit</dt>
                <dd class="mt-1 text-lg font-semibold tabular-nums text-ink">158</dd>
            </div>
            <div>
                <dt class="text-muted">Late</dt>
                <dd class="mt-1 text-lg font-semibold tabular-nums text-danger-ink">16</dd>
            </div>
        </dl>
    </zb:card.body>

    <zb:card.footer>
        <span class="text-xs text-muted">Last updated 09:42</span>
        <zb:button size="sm" variant="soft" class="ms-auto">Go to shipping report</zb:button>
    </zb:card.footer>
</zb:card>
PropValues
zb:card.headertitle, subtitle; slot: header content · actions slot
zb:card.bodypadding (default true)
zb:card.footerFooter

Equal-height cards

Equal-height cards: view
BLADE

The card is a vertical flex box and its body fills the remaining height (flex-1). Cards side by side in a grid keep their footers aligned, even when their texts differ in length.

blade
<div class="grid gap-4 md:grid-cols-3">
    <zb:card title="Kadıköy warehouse" subtitle="148 orders">
        <p class="text-sm text-dim">36 orders are waiting to ship.</p>
        <zb:slot:footer><zb:button size="sm" variant="ghost">Show orders</zb:button></zb:slot:footer>
    </zb:card>

    <zb:card title="Ankara warehouse" subtitle="205 orders">
        <p class="text-sm text-dim">198 orders shipped this month. Because of the new carrier contract, Thursday pickups start two hours early; warehouse teams need to update their packing plans accordingly.</p>
        <zb:slot:footer><zb:button size="sm" variant="ghost">Show orders</zb:button></zb:slot:footer>
    </zb:card>

    <zb:card title="Izmir warehouse" subtitle="64 orders">
        <p class="text-sm text-dim">All orders have shipped.</p>
        <zb:slot:footer><zb:button size="sm" variant="ghost">Show orders</zb:button></zb:slot:footer>
    </zb:card>
</div>

Free-form content

Free-form content: view
BLADE

Use the card as a free surface without a title; welcome and summary cards are built this way.

blade
<zb:card>
    <div class="flex flex-wrap items-center justify-between gap-6">
        <div class="max-w-md">
            <h3 class="text-lg font-semibold text-primary-ink">Good morning, Ayşe 👋</h3>
            <p class="mt-2 text-sm text-dim">214 orders came in yesterday, 18% more than last week's average.</p>
            <zb:button size="sm" variant="outline" class="mt-4">Open sales report</zb:button>
        </div>
        <zb:icon name="shopping-bag" size="24" stroke="1.2" class="text-primary-line/30" />
    </div>
</zb:card>

Header with a badge, edge-to-edge body

Header with a badge, edge-to-edge body: view
BLADE

With title, the slot is added to the header, e.g. a count badge. :padding="false" opens the body up to the edges.

blade
<zb:card>
    <zb:card.header title="Support team">
        <zb:badge>8 people</zb:badge>
    </zb:card.header>

    <zb:card.body :padding="false">
        <ul class="divide-y divide-line-soft border-t border-line-soft text-sm">
            <li class="flex items-center justify-between gap-3 px-5 py-3">
                <span class="font-medium text-ink">Ahmet Yılmaz</span>
                <span class="text-muted">Billing · 42 tickets</span>
            </li>
            <li class="flex items-center justify-between gap-3 px-5 py-3">
                <span class="font-medium text-ink">Elif Kaya</span>
                <span class="text-muted">Technical support · 37 tickets</span>
            </li>
            <li class="flex items-center justify-between gap-3 px-5 py-3">
                <span class="font-medium text-ink">Murat Demir</span>
                <span class="text-muted">Shipping and returns · 51 tickets</span>
            </li>
        </ul>
    </zb:card.body>
</zb:card>

Developer notes

Events, hooks and details
  • Header examples with a dropdown are on the Cards with actions page.
  • Collapsing and closing happen only in the browser; when the page is reloaded, the card is open again.
  • When the content starts with a part, the card draws only its box; the collapse and close buttons still appear in the header.
  • Give a card built from parts inside a collapsible card :collapsible="false"; otherwise the inner header shows the outer card's buttons.
Zubazar UI · ZubazarDesigned for people.