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

Option cards

Turns a radio or checkbox into a clickable card with a title, description and icon, for a few options that need explaining.

zb:option-card zubazar/ui-pro

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

Single choice

Single choice: view
BLADE

Give the cards in a group the same name and each its own value; mark the initial choice with checked.

blade
<div class="grid gap-3 md:grid-cols-3">
    <zb:option-card name="billing_period" value="monthly" title="Monthly" description="Renews every month" />
    <zb:option-card name="billing_period" value="yearly" title="Yearly" description="Two months free" checked />
    <zb:option-card name="billing_period" value="lifetime" title="Lifetime" description="One-time payment" />
</div>
PropValues
typeradio | checkbox
nameGroup name
valueSubmitted value
checkedInitially selected

With icons

With icons: view
BLADE

icon adds an icon to the right of the title; it turns to the brand colour when the card is selected.

blade
<div class="grid gap-3 md:grid-cols-3">
    <zb:option-card name="shipping_method" value="standard" title="Standard shipping" description="Delivered in 2–4 business days" icon="truck" checked />
    <zb:option-card name="shipping_method" value="express" title="Express shipping" description="At your door the next day" icon="bolt" />
    <zb:option-card name="shipping_method" value="pickup" title="Store pickup" description="Collect it at your nearest branch" icon="building-storefront" />
</div>
PropValues
iconzb:icon name

Multiple choice

Multiple choice: view
BLADE

type="checkbox" allows several cards; in a classic form add [] to the name.

blade
<div class="grid gap-3 md:grid-cols-2">
    <zb:option-card type="checkbox" name="notifications[]" value="sms" title="SMS" description="Shipping status updates" checked />
    <zb:option-card type="checkbox" name="notifications[]" value="email" title="Email" description="Monthly summary" />
</div>
PropValues
typecheckbox

Disabled option

Disabled option: view
BLADE

disabled dims the card and blocks the choice.

blade
<div class="grid gap-3 md:grid-cols-2">
    <zb:option-card name="payment" value="card" title="Credit card" description="Pay in full or in installments" checked />
    <zb:option-card name="payment" value="cod" title="Cash on delivery" description="Not available in this region" disabled />
</div>
PropValues
disabledCannot be selected and looks dimmed

With Livewire

BLADE

Give only wire:model; the group name and the ids come from the property, and checkbox cards bind to an array.

blade
@foreach (['standard' => 'Standard shipping', 'express' => 'Express shipping', 'pickup' => 'Store pickup'] as $value => $label)
    <zb:option-card wire:model.live="shippingMethod" :value="$value" :title="$label" />
@endforeach

<zb:option-card type="checkbox" wire:model="channels" value="sms" title="SMS" />
PropValues
wire:modelRadio: a single value · checkbox: an array

Props

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

PropTypeDefaultDescription
title— — Card title (required)
description—nullDescription below the title; otherwise the slot content
type—radioradio · checkbox
name—nullGroup name; otherwise the wire:model value
value—nullValue submitted when selected
checkedbooleanfalseInitially selected
icon—nullzb:icon name to the right of the title; in the brand color when the card is selected
input-class—nullClasses of the inner radio or checkbox itself

Slots: Default slot: shown as the description when description is not given.

Advanced

1 example

Rich description

Rich description: view
BLADE

Without description, the content you write inside the card becomes the description; use it for parts to highlight, such as a price.

blade
<div class="grid gap-3 md:grid-cols-2">
    <zb:option-card name="plan" value="starter" title="Starter" checked>
        <strong class="text-ink">₺1,250</strong> per month, up to 5 users
    </zb:option-card>
    <zb:option-card name="plan" value="pro" title="Professional">
        <strong class="text-ink">₺2,000</strong> per month plus priority support
    </zb:option-card>
</div>
PropValues
descriptionPlain-text description
(slot)Content shown when there is no description

Developer notes

Events, hooks and details
  • class, style, x-show and wire:key go on the card; other attributes such as disabled, required, wire:model, aria-* and data-* go to the inner input.
  • On a validation error the card gets a red border; a single checkbox card shows the message itself, while radio cards and checkbox lists show it once below the group (zb:radio-group, zb:checkbox-group).
Zubazar UI · ZubazarDesigned for people.