shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Spinner

An indicator that can be used to show a loading state.

Processing payment...
$100.00
package examples import (

Installation

shadcn-templ add spinner

Usage

import "github.com/axadrn/shadcn-templ/v2/components/spinner"
@spinner.Spinner()

Customization

You can replace the default spinner icon with any other icon by editing the Spinner component.

package examples import "github.com/axadrn/shadcn-templ/v2/components/icon"
components/spinner/spinner.templ
templ Spinner(props ...Props) {	{{ var p Props }}	if len(props) > 0 {		{{ p = props[0] }}	}	@icon.Loader(icon.Props{		Class: utils.CN("size-4 animate-spin", p.Class),		Attributes: templ.Attributes{			"role":       "status",			"aria-label": "Loading",		},	})}

Size

Use the size-* utility class to change the size of the spinner.

package examples import "github.com/axadrn/shadcn-templ/v2/components/spinner"

Button

Add a spinner to a button to indicate a loading state. Place the @spinner.Spinner() before the label with data-icon="inline-start" for a start position, or after the label with data-icon="inline-end" for an end position.

package examples import (

Badge

Add a spinner to a badge to indicate a loading state. Place the @spinner.Spinner() before the label with data-icon="inline-start" for a start position, or after the label with data-icon="inline-end" for an end position.

Syncing Updating Processing
package examples import (

Input Group

Validating...
package examples import (

Empty

Processing your request
Please wait while we process your request. Do not refresh the page.
package examples import (

API Reference

Spinner

The Spinner component renders a spinning loader icon with role="status".

Prop Type Default
Class string -