Files
zeekay 15f639161d fix: Update package references and 3D card demos
- Fix 3D card component demos with proper content in both default and new-york themes
- Update all 170+ CLI installation commands from 'npx hanzo-ui@latest' to 'npx @hanzo/ui@latest'
- Update CLAUDE.md to reflect correct package naming
- Rebuild component registry with updated demos
2025-10-18 23:47:06 -07:00

131 lines
2.3 KiB
Plaintext

---
title: Spinner
description: An indicator that can be used to show a loading state.
component: true
---
<ComponentPreview 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 @hanzo/ui@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" />
<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 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 name="spinner-size" />
### Color
Use the `text-` utility class to change the color of the spinner.
<ComponentPreview 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 name="spinner-button" />
### Badge
You can also use a spinner inside a badge.
<ComponentPreview name="spinner-badge" />
### Input Group
Input Group can have spinners inside `<InputGroupAddon>`.
<ComponentPreview name="spinner-input-group" />
### Empty
<ComponentPreview name="spinner-empty" />
### Item
Use the spinner inside `<ItemMedia>` to indicate a loading state.
<ComponentPreview name="spinner-item" />
## API Reference
### Spinner
Use the `Spinner` component to display a spinner.
| Prop | Type | Default |
| ----------- | -------- | ------- |
| `className` | `string` | `` |
```tsx
<Spinner />
```