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

Component spinner-demo not found in registry.

Installation

npx shadcn@latest add spinner

Usage

import { Spinner } from "@/components/ui/spinner"
<Spinner />

Customization

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

Component spinner-custom not found in registry.

import { LoaderIcon } from "lucide-react"

import { cn } from "@/lib/utils"

function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
  return (
    <LoaderIcon
      role="status"
      aria-label="Loading"
      className={cn("size-4 animate-spin", className)}
      {...props}
    />
  )
}

export { Spinner }

Examples

Size

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

Component spinner-size not found in registry.

Color

Use the text- utility class to change the color of the spinner.

Component spinner-color not found in registry.

Button

Add a spinner to a button to indicate a loading state. The <Button /> will handle the spacing between the spinner and the text.

Component spinner-button not found in registry.

Badge

You can also use a spinner inside a badge.

Component spinner-badge not found in registry.

Input Group

Input Group can have spinners inside <InputGroupAddon>.

Component spinner-input-group not found in registry.

Empty

Component spinner-empty not found in registry.

Item

Use the spinner inside <ItemMedia> to indicate a loading state.

Component spinner-item not found in registry.

API Reference

Spinner

Use the Spinner component to display a spinner.

PropTypeDefault
classNamestring``
<Spinner />