import { Spinner } from '@raystack/apsara';
<Spinner size={1} />
<Spinner size={2} />
<Spinner size={3} />
<Spinner size={4} />
<Spinner size={5} />
<Spinner size={6} />
<Spinner color="default" />
<Spinner color="neutral" />
<Spinner color="accent" />
<Spinner color="danger" />
<Spinner color="success" />
<Spinner color="attention" />
In buttons
import { Button } from '@raystack/apsara';
<Button disabled>
<Spinner size={2} />
Loading...
</Button>
Centered loading
<div style={{ display: 'flex', justifyContent: 'center', padding: '2rem' }}>
<Spinner size={4} />
</div>
Full page loading
<div style={{
position: 'fixed',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
background: 'rgba(0, 0, 0, 0.5)'
}}>
<Spinner size={6} />
</div>
With text
import { Flex, Text } from '@raystack/apsara';
<Flex direction="column" align="center" gap="2">
<Spinner size={4} />
<Text>Loading your data...</Text>
</Flex>
Loading states
Inline loading
function InlineLoader() {
return (
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '8px' }}>
<Spinner size={1} />
Processing...
</span>
);
}
Card loading
import { Card } from '@raystack/apsara';
function LoadingCard() {
return (
<Card>
<Flex direction="column" align="center" gap="3" style={{ padding: '2rem' }}>
<Spinner size={4} color="accent" />
<Text>Loading content...</Text>
</Flex>
</Card>
);
}
Conditional loading
function DataDisplay() {
const { data, isLoading } = useData();
if (isLoading) {
return (
<Flex justify="center" style={{ padding: '4rem' }}>
<Spinner size={5} />
</Flex>
);
}
return <div>{data}</div>;
}
Button loading state
function SubmitButton() {
const [loading, setLoading] = useState(false);
const handleSubmit = async () => {
setLoading(true);
await submitForm();
setLoading(false);
};
return (
<Button onClick={handleSubmit} disabled={loading}>
{loading ? (
<>
<Spinner size={2} />
Submitting...
</>
) : (
'Submit'
)}
</Button>
);
}
API reference
Spinner
size
1 | 2 | 3 | 4 | 5 | 6
default:"1"
The size of the spinner. Larger numbers create bigger spinners.
color
'default' | 'neutral' | 'accent' | 'danger' | 'success' | 'attention'
default:"'neutral'"
The color variant of the spinner.
Additional CSS class names to apply to the spinner.