Files
shadcn-ui/apps/v4/content/docs/components/base/spinner.mdx
shadcn 74c4c7508b docs: review all docs (#10058)
* docs: review all docs

* fix

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* docs(spinner): reintroduce data-icon attribute guidance in radix spinner docs (#10059)

* Initial plan

* docs: add data-icon attribute instructions to radix/spinner.mdx button and badge sections

Co-authored-by: shadcn <124599+shadcn@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shadcn <124599+shadcn@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-03-16 13:29:23 +04:00

114 lines
2.4 KiB
Plaintext

---
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" />
## Installation
<CodeTabs>
<TabsList>
<TabsTrigger value="cli">Command</TabsTrigger>
<TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">
```bash
npx shadcn@latest add spinner
```
</TabsContent>
<TabsContent value="manual">
<Steps className="mb-0 pt-2">
<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" />
### Button
Add a spinner to a button to indicate a loading state. Place the `<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.
<ComponentPreview styleName="base-nova" name="spinner-button" />
### Badge
Add a spinner to a badge to indicate a loading state. Place the `<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.
<ComponentPreview styleName="base-nova" name="spinner-badge" />
### Input Group
<ComponentPreview styleName="base-nova" name="spinner-input-group" />
### Empty
<ComponentPreview styleName="base-nova" name="spinner-empty" />
## RTL
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
<ComponentPreview styleName="base-nova" name="spinner-rtl" direction="rtl" />