The Stock Badge component displays a colored badge indicating stock levels. It automatically changes color based on the stock quantity threshold.
Preview
Usage
<x-shopper::stock-badge :stock="$product->stock" />
Props
The stock quantity to display. Values below 10 show as red (low stock), 10 or above show as green.
Behavior
| Stock Value | Color | Meaning |
|---|
< 10 | Red | Low stock warning |
>= 10 | Green | Stock OK |
Examples
Low Stock
<x-shopper::stock-badge :stock="3" />
Normal Stock
<x-shopper::stock-badge :stock="50" />
In a Table
<table>
<tr>
<td>Product Name</td>
<td>
<x-shopper::stock-badge :stock="$product->stock" />
</td>
</tr>
</table>
Blade Component Source
@props([
'stock',
])
<span
@class([
'me-2 inline-flex rounded-full px-1.5 text-xs leading-5 font-semibold',
'bg-danger-100 text-danger-800' => $stock < 10,
'bg-success-100 text-success-800' => $stock >= 10,
])
>
{{ $stock }}
</span>