@@ -3,9 +3,13 @@ title: React Spinner Component
33description : A React spinner component used as a loading indicator during ongoing processes. Displays animated spinners to show loading states in applications.
44---
55
6+ import SpinnerButtonPreview from " @/components/preview/spinner/spinner-button-preview" ;
7+ import SpinnerCustomPreview from " @/components/preview/spinner/spinner-custom-preview" ;
8+ import SpinnerPreview from " @/components/preview/spinner/spinner-preview" ;
9+ import SpinnerSizesPreview from " @/components/preview/spinner/spinner-sizes-preview" ;
10+ import SpinnerTypesPreview from " @/components/preview/spinner/spinner-types-preview" ;
611import { getFileContent } from " @/utils/get-file-content" ;
712import { Accordion , Accordions } from " fumadocs-ui/components/accordion" ;
8- import SpinnerPreview from " @/components/preview/spinner-preview" ;
913
1014# Spinner
1115
@@ -14,20 +18,21 @@ React Spinner components are used to indicate that an action or process is curre
1418This Spinner component is built with React and styled using Tailwind CSS. It supports multiple visual styles and sizes, making it easy to adapt to buttons, inline UI, or full-page loading states.
1519
1620<ComponentPreview
17- codeSnippet = { getFileContent (" /src/components/preview/spinner-preview.tsx" )}
21+ codeSnippet = { getFileContent (
22+ " /src/components/preview/spinner/spinner-preview.tsx"
23+ )}
1824>
1925 <SpinnerPreview />
2026</ComponentPreview >
2127
2228## Installation
2329
24- <Accordions >
30+ <Accordions defaultValue = " CLI " >
2531<Accordion title = " CLI" >
2632Install the component using the Tailgrids CLI.
2733``` npm
2834npx @tailgrids/cli add spinner
2935```
30-
3136</Accordion >
3237
3338<Accordion title = " Manual" >
@@ -68,27 +73,66 @@ You'll also need the spinner SVG assets referenced in the component (`default.sv
6873</Accordions >
6974
7075## Usage
76+
7177Import the component and render it where a loading state is needed .
7278
7379``` tsx
7480import { Spinner } from " @/registry/core/spinner" ;
7581
76- export default () => <Spinner />;
82+ export default function SpinnerExample() {
83+ return <Spinner />;
84+ }
7785```
7886
7987## Examples
8088
89+ ### Types
90+
91+ The Spinner component has ` default ` , ` dotted ` , and ` dotted-round ` types.
92+
93+ <ComponentPreview
94+ codeSnippet = { getFileContent (
95+ " /src/components/preview/spinner/spinner-types-preview.tsx"
96+ )}
97+ >
98+ <SpinnerTypesPreview />
99+ </ComponentPreview >
100+
101+ ### Sizes
102+
103+ The Spinner component supports five pre-defined sizes: ` sm ` , ` md ` , ` lg ` , ` xl ` , and ` xxl ` .
104+
105+ <ComponentPreview
106+ codeSnippet = { getFileContent (
107+ " /src/components/preview/spinner/spinner-sizes-preview.tsx"
108+ )}
109+ >
110+ <SpinnerSizesPreview />
111+ </ComponentPreview >
112+
81113### In Buttons
82- Use spinners inside buttons to indicate pending actions.
83114
84- ``` tsx
85- import { Button } from " @/registry/core/button" ;
115+ Spinners can be integrated into buttons to provide visual feedback during loading or pending actions.
86116
87- <Button disabled >
88- <Spinner size = " sm" />
89- Loading...
90- </Button >;
91- ```
117+ <ComponentPreview
118+ codeSnippet = { getFileContent (
119+ " /src/components/preview/spinner/spinner-button-preview.tsx"
120+ )}
121+ >
122+ <SpinnerButtonPreview />
123+ </ComponentPreview >
124+
125+ ### Custom
126+
127+ You can customize the spinner's behavior and appearance using Tailwind CSS utility classes.
128+
129+ <ComponentPreview
130+ codeSnippet = { getFileContent (
131+ " /src/components/preview/spinner/spinner-custom-preview.tsx"
132+ )}
133+ >
134+ <SpinnerCustomPreview />
135+ </ComponentPreview >
92136
93137## API Reference
94138
@@ -115,11 +159,3 @@ import { Button } from "@/registry/core/button";
115159- When used in buttons, ensure the button has descriptive text or aria-label
116160- Consider using ` aria-busy="true" ` on parent containers during loading states
117161- Animation respects ` prefers-reduced-motion ` through Tailwind's ` animate-spin `
118-
119- ## Notes
120-
121- - Uses CSS ` animate-spin ` for smooth rotation animation
122- - Spinner images should be SVG format for crisp rendering at all sizes
123- - Three different visual styles available for different design contexts
124- - Commonly used in buttons, overlays, and page loading states
125- - Works well with the Button component's disabled state
0 commit comments