index.tsx 845 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use client";
  2. import clsx from "clsx";
  3. import type { ComponentProps } from "react";
  4. import styles from "./index.module.scss";
  5. export const VARIANTS = [
  6. "neutral",
  7. "info",
  8. "warning",
  9. "error",
  10. "data",
  11. "success",
  12. "muted",
  13. ] as const;
  14. export const STYLES = ["filled", "outline"] as const;
  15. export const SIZES = ["xs", "md", "lg"] as const;
  16. type Props = ComponentProps<"span"> & {
  17. variant?: (typeof VARIANTS)[number] | undefined;
  18. style?: (typeof STYLES)[number] | undefined;
  19. size?: (typeof SIZES)[number] | undefined;
  20. };
  21. export const Badge = ({
  22. className,
  23. variant = "neutral",
  24. size = "md",
  25. style = "filled",
  26. children,
  27. ...props
  28. }: Props) => (
  29. <span
  30. className={clsx(styles.badge, className)}
  31. data-variant={variant}
  32. data-size={size}
  33. data-style={style}
  34. {...props}
  35. >
  36. {children}
  37. </span>
  38. );