Design system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
902 B

  1. import * as React from 'react';
  2. import clsx from 'clsx';
  3. export type BadgeDerivedElement = HTMLSpanElement;
  4. export interface BadgeProps extends React.HTMLProps<BadgeDerivedElement> {
  5. rounded?: boolean;
  6. }
  7. export const Badge = React.forwardRef<BadgeDerivedElement, BadgeProps>(({
  8. children,
  9. rounded = false,
  10. className,
  11. ...etcProps
  12. }, forwardedRef) => (
  13. <span
  14. {...etcProps}
  15. ref={forwardedRef}
  16. className={clsx(
  17. 'relative h-6 min-w-6 flex items-center justify-center text-xs font-bold overflow-hidden font-semi-expanded',
  18. 'before:absolute before:top-0 before:left-0 before:w-full before:h-full before:bg-current before:opacity-25',
  19. {
  20. 'rounded-full px-2': rounded,
  21. 'rounded px-1': !rounded,
  22. },
  23. className,
  24. )}
  25. >
  26. <span className="relative w-full">
  27. {children}
  28. </span>
  29. </span>
  30. ));
  31. Badge.displayName = 'Badge';