Category card
A card leading to a category page, with the category's picture, name and number of products.
zb:shop.category-card zubazar/ui-pro
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
One card
BLADE
The card takes an Zubazar\Commerce\Data\Category and fills the width of its box.
<zb:shop.category-card :category="$category" />
Category grid
BLADE
Shop::categories() returns the categories in menu order; the home page lays them out in two columns on phones and four on wide screens.
<div class="grid grid-cols-2 gap-3 sm:gap-5 md:grid-cols-4">
@foreach (\Zubazar\Commerce\Shop::categories() as $category)
<zb:shop.category-card :category="$category" />
@endforeach
</div>
Category data
PHP
The categories come from the store's categories() method; the card takes the name, the link, the drawing and the colour family from this data.
use Zubazar\Commerce\Data\Category;
public function categories(): Collection
{
return collect([
Category::fromArray(['id' => 1, 'slug' => 'shop-electronics', 'name' => 'Electronics', 'icon' => 'cpu-chip', 'hue' => 'violet', 'shape' => 'headphones']),
Category::fromArray(['id' => 2, 'slug' => 'shop-home-living', 'name' => 'Home & Living', 'icon' => 'home', 'hue' => 'amber', 'shape' => 'lamp']),
]);
}
| Prop | Values |
|---|---|
name | The card's title (a string or one value per language) |
slug | The address of the category page |
shape, hue | The card's picture (zb:shop.product-visual) |
icon | The icon in the menus and on the categories page; the card does not use it |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
category | — | — | The category shown (Zubazar\Commerce\Data\Category); required |
Developer notes
- The categories section of the home page lays these cards out; the picture is drawn from the category's drawing (
shape) and colour family (hue). - The number of products comes from the store's
productCount()method. - The card's link is made from the
web.categories.showroute and the category'sslug.