Spinner
A simple spinner for displaying loading state
Installation
1
Copy and paste the following code into your project.
import { Loader2 } from 'lucide-react';
import React from 'react';
import { cn } from '@/lib/utils';
export type SpinnerProps = {
size?: 'small' | 'medium' | 'large';
className?: string;
children?: React.ReactNode;
show?: boolean;
};
export function Spinner({ size = 'medium', show = true, className, children }: SpinnerProps) {
return (
<span className={cn('flex flex-col items-center justify-center', !show && 'hidden')}>
<Loader2
className={cn(
'animate-spin text-primary',
size === 'small' && 'h-6 w-6',
size === 'medium' && 'h-8 w-8',
size === 'large' && 'h-12 w-12',
className,
)}
/>
{children}
</span>
);
}
2
Update the import paths to match your project setup.
Usage
Properties
Property | Type | Default |
---|---|---|
className | string | |
size | 'small' | 'medium' | 'large' | medium |
show | boolean | true |
children | React.ReactNode |