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

Product card

The card of the product lists: the picture, the badges, the category, the name, the rating and the price. It has no buttons; you put yours in its four places (the corner, the picture's foot, beside the price, the card's foot).

zb:shop.product-card zubazar/ui-pro

PRO

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

One card

One card: view
BLADE

The card takes an Zubazar\Commerce\Data\Product and fills the width of its box.

blade
<zb:shop.product-card :product="$product" />

A product with options and low stock

A product with options and low stock: view
BLADE

The product's data decides what the card shows: the sale, new and stock badges, and with a low stock the number left.

blade
<zb:shop.product-card :product="$tshirt" />
PropValues
old_priceHigher than the price: the discount badge (-20%) and the old price struck through
newtrue: the "New" badge
stockFrom 1 to 5: "Only 3 left" under the name
rating, reviewsThe stars, the score and the number of reviews (zb:shop.rating)
categoryThe category link above the name
visualshape and hue: the card's picture (zb:shop.product-visual)

Your buttons in its places

Your buttons in its places: view
BLADE

The card is free of content: you give the buttons and their words ("Add to cart", "Quick view"). corner (round icons in the corner: zb:shop.icon-button), overlay (the picture's foot), action (beside the price) and footer (the card's foot). The corner and the picture's foot show under a mouse (always on a touch screen; always with reveal="always"). The theme's lists draw the card with your card view: commerce.card.view.

blade
<zb:shop.product-card :product="$product">
    <zb:slot:corner>
        <zb:shop.icon-button icon="eye" label="Quick view" data-zb-shop-quick-view="{{ $product->slug }}" />
    </zb:slot:corner>
    <zb:slot:overlay>
        <zb:button class="w-full">Add to cart</zb:button>
    </zb:slot:overlay>
</zb:shop.product-card>

<zb:shop.product-card :product="$product" hover="zoom backdrop" hover-text="Look">
    <zb:slot:action><zb:button size="sm">Add</zb:button></zb:slot:action>
</zb:shop.product-card>

A scrolling row

A scrolling row: view
BLADE

The card adds class to its own box; here the cards have a fixed width, stand side by side and the row scrolls sideways.

blade
<div class="flex snap-x gap-4 overflow-x-auto pb-2">
    @foreach ($recentlyViewed as $product)
        <zb:shop.product-card :product="$product" key-prefix="recent" class="w-56 flex-none snap-start" />
    @endforeach
</div>

Props

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

PropTypeDefaultDescription
product— — The product shown (Zubazar\Commerce\Data\Product); required
key-prefix—cardThe key prefix of the card's Livewire component; keeps two lists apart when the same product is in both
aspect—nullThe picture's shape: default (4:3.6) · square (1:1) · portrait (3:4, a model photo) · tall (4:5); null: commerce.card.image_aspect, else the store's (commerce.image_aspect)
hover—nullUnder a mouse: zoom · swap (the second photo; for a product without photos, the drawing's second angle with placeholder_views 3) · backdrop (the picture dims) · none; several with spaces: "swap backdrop"; null: commerce.card.hover (zoom)
hover-text—nullA word in the middle of the picture under a mouse ("Quick look"); null: commerce.card.hover_text (none)
reveal—hoverWhen the corner and the picture's foot show: hover (under a mouse or the keyboard's focus; always on a touch screen) · always. One pressed (aria-pressed) or just added (data-added) stays
price-line—nullThe price line: stacked (the old price above; a row's prices on one line) · inline (side by side); null: commerce.card.price
out-of-stock—nullThe "Out of stock" badge; null: at a stock of 0 (pass false for a product sold on a quote)
layout—gridgrid (the picture above) · list (the picture on the left, the name, rating, short description and price beside it; under 28rem wide it stands up again). Your card view passes it on with `:layout="$layout ?? 'grid'"`

Slots: corner: round icons in the picture's corner (zb:shop.icon-button: label, icon, pressed, href; the label becomes a tip on its left). overlay: the picture's foot, centred (class="w-full" for the whole width). action: beside the price. footer: under the price line, always shown. The kit's hooks work on your buttons: data-zb-shop-add-to-cart ("Added" and the flight to the cart, cart-updated), data-zb-shop-quick-view, data-zb-shop-favorite.

Developer notes

Events, hooks and details
  • The theme's showcases, product lists and related products draw the card with your card view: commerce.card.view (the view gets $product, $keyPrefix, $class); without it the kit's card without buttons.
  • The prices of a row of cards stand on one line: the name always keeps two lines, and the old price has its own line above the price (empty without a discount).
  • For all of the store's cards: config/zubazar-ui-pro.php › commerce.card (view, hover, hover_text, image_aspect, price), or SHOP_CARD_HOVER, SHOP_CARD_HOVER_TEXT, SHOP_CARD_IMAGE_ASPECT. The gallery may stay 3:4 while the cards are 4:5: SHOP_CARD_IMAGE_ASPECT=tall.
  • With reduced motion the card's effects stay still.
  • The card uses the theme's corner and surface settings.
  • With a stock of five or fewer, a line under the name says how many are left.
  • The same product can be in two lists on a page: when each list sets its own key-prefix, the keys of the cards' Livewire components never clash.
Zubazar UI · ZubazarDesigned for people.