chenzhaoyang
2025-12-17 063da0bf961e1d35e25dc107f883f7492f4c5a7c
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
import type { CSSProperties } from "react";
import styles from "./spinner.module.scss";
import { cn } from "@humansignal/shad/utils";
 
export type SpinnerProps = {
  className?: string;
  style?: CSSProperties;
  size?: number;
  stopped?: boolean;
};
 
export const Spinner = ({ className, style, size = 32, stopped = false }: SpinnerProps) => {
  const fullClassName = cn(styles.spinner, className);
  const bodyClassName = cn(styles.body, stopped ? styles.stopped : "");
 
  const sizeWithUnit = typeof size === "number" ? `${size}px` : size;
 
  return (
    <div className={fullClassName} style={{ ...(style ?? {}), "--spinner-size": sizeWithUnit }}>
      <div className={bodyClassName}>
        <span />
        <span />
        <span />
        <span />
      </div>
    </div>
  );
};