Checkbox component with SVG tick
Styling a checkbox by swapping out SVGs
Last updated
Styling a checkbox by swapping out SVGs
Last updated
The effect illustrated here, uses x-show to switch between two different SVGs, one being a circle and one being a circle with a check mark inside.
Using x-on:click
in the checkbox label updates the status of the checked
Alpine attribute whenever the state of the checkbox changes.
The icons used were imported from Steve Schoger's heroicons and converted to Laravel 7 components. Check out https://heroicons.dev/ for an easy way to find and copy the SVG you need. The empty circle was created by taking one of the other circular icons and deleting one of the paths.
The actual checkbox input is hidden, but remains in sync. The technique needs some ARIA tags adding to ensure accessibility.
The component is included in the view with name
and label
props;