---
title: Spinner
description: An indicator that can be used to show a loading state.
base: base
component: true
---

<ComponentPreview
  styleName="base-nova"
  name="spinner-demo"
  className="[&_.preview]:p-6"
/>

## Installation

<CodeTabs>

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add spinner
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource
  name="spinner"
  title="components/ui/spinner.tsx"
  styleName="base-nova"
/>

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</CodeTabs>

## Usage

```tsx
import { Spinner } from "@/components/ui/spinner"
```

```tsx
<Spinner />
```

## Customization

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

<ComponentPreview styleName="base-nova" name="spinner-custom" />

```tsx showLineNumbers title="components/ui/spinner.tsx"
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.

<ComponentPreview styleName="base-nova" name="spinner-size" />

### Color

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

<ComponentPreview styleName="base-nova" name="spinner-color" />

### Button

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

<ComponentPreview styleName="base-nova" name="spinner-button" />

### Badge

You can also use a spinner inside a badge.

<ComponentPreview styleName="base-nova" name="spinner-badge" />

### Input Group

Input Group can have spinners inside `<InputGroupAddon>`.

<ComponentPreview styleName="base-nova" name="spinner-input-group" />

### Empty

<ComponentPreview styleName="base-nova" name="spinner-empty" />

### Item

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

<ComponentPreview styleName="base-nova" name="spinner-item" />

## API Reference

### Spinner

Use the `Spinner` component to display a spinner.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | ``      |

```tsx
<Spinner />
```
