Loader
Animated spinner for loading states, sized and colored with classes.
The loader is a spinning SVG for loading states. Shopper's forms place it in their save button, where it shows while Livewire runs the save method.
Preview
The preview shows the loader at its default size.
Usage
The loader takes no prop. Add Livewire's wire:loading and wire:target attributes to show it only while a method runs:
<x-shopper::loader wire:loading wire:target="save" />Attributes
Every attribute goes to the svg element. The class attribute is merged with the default classes, so a size you pass replaces the default one.
| Attribute | Default | Description |
|---|---|---|
x-shopper::loaderrenders a <svg> element | ||
classstring | size-5 animate-spin | Classes for the size and the color. The spinner is drawn with |
Examples
The examples below change the size and the color, and place the loader in a button and a page.
Different Sizes
Pass a size-* class.
This Blade renders the three loaders, from size-4 (16 pixels) to size-6 (24 pixels):
<x-shopper::loader class="size-4" />
<x-shopper::loader class="size-5" />
<x-shopper::loader class="size-6" />With Color
Pass a text color class. The theme tokens follow dark mode:
<x-shopper::loader class="text-primary-500" />
<x-shopper::loader class="text-sh-fg-muted" />In a Button
Shopper's settings forms show the loader in the submit button while the store method runs, and disable the button meanwhile:
<x-filament::button type="submit" wire:loading.attr="disabled">
<x-shopper::loader wire:loading wire:target="store" class="text-white" />
Save
</x-filament::button>Loading State
Center a larger loader in an area while its content loads:
<div wire:loading.flex wire:target="loadOrders" class="items-center justify-center py-8">
<x-shopper::loader class="text-primary-500 size-8" />
</div>Blade Component Source
The view is resources/views/components/loader.blade.php in the shopper/framework package:
@blaze(memo: true)
<svg
{{ $attributes->twMerge(['class' => 'size-5 animate-spin']) }}
fill="none"
viewBox="0 0 24 24"
aria-hidden="true"
>
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>Last updated on
Edit on GitHub