-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathspinner.tsx
50 lines (46 loc) · 964 Bytes
/
spinner.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { cn } from '@/utils/cn';
const sizes = {
sm: 'h-4 w-4',
md: 'h-8 w-8',
lg: 'h-16 w-16',
xl: 'h-24 w-24',
};
const variants = {
light: 'text-white',
primary: 'text-slate-600',
};
export type SpinnerProps = {
size?: keyof typeof sizes;
variant?: keyof typeof variants;
className?: string;
};
export const Spinner = ({
size = 'md',
variant = 'primary',
className = '',
}: SpinnerProps) => {
return (
<>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={cn(
'animate-spin',
sizes[size],
variants[variant],
className,
)}
>
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
<span className="sr-only">Loading</span>
</>
);
};