Function
Spinner
({
className,
size,
variant,
speed,
type = 'circle',
ref,
...props
}: SpinnerProps)
Source from the content-addressed store, hash-verified
| 38 | } |
| 39 | |
| 40 | const Spinner = ({ |
| 41 | className, |
| 42 | size, |
| 43 | variant, |
| 44 | speed, |
| 45 | type = 'circle', |
| 46 | ref, |
| 47 | ...props |
| 48 | }: SpinnerProps) => { |
| 49 | const baseClasses = spinnerVariants({ size, variant, speed }); |
| 50 | const animationClass = type === 'pulse' ? 'animate-pulse' : 'animate-spin'; |
| 51 | const spinnerClasses = cn(baseClasses, animationClass, className); |
| 52 | |
| 53 | switch (type) { |
| 54 | case 'circle': |
| 55 | return ( |
| 56 | <svg |
| 57 | ref={ref} |
| 58 | className={spinnerClasses} |
| 59 | xmlns="http://www.w3.org/2000/svg" |
| 60 | fill="none" |
| 61 | viewBox="0 0 24 24" |
| 62 | {...props} |
| 63 | > |
| 64 | <circle |
| 65 | className="opacity-25" |
| 66 | cx="12" |
| 67 | cy="12" |
| 68 | r="10" |
| 69 | stroke="currentColor" |
| 70 | strokeWidth="4" |
| 71 | /> |
| 72 | <path |
| 73 | className="opacity-75" |
| 74 | fill="currentColor" |
| 75 | d="m4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" |
| 76 | /> |
| 77 | </svg> |
| 78 | ); |
| 79 | |
| 80 | case 'dots': |
| 81 | return ( |
| 82 | <svg |
| 83 | ref={ref} |
| 84 | className={baseClasses} |
| 85 | xmlns="http://www.w3.org/2000/svg" |
| 86 | fill="currentColor" |
| 87 | viewBox="0 0 24 24" |
| 88 | {...props} |
| 89 | > |
| 90 | <circle cx="4" cy="12" r="3"> |
| 91 | <animate |
| 92 | attributeName="opacity" |
| 93 | dur="1s" |
| 94 | repeatCount="indefinite" |
| 95 | values="0;1;0" |
| 96 | begin="0s" |
| 97 | /> |
Callers
nothing calls this directly
Tested by
no test coverage detected