Chip.tsx 725 B

12345678910111213141516171819202122232425
  1. import classnames from 'classnames';
  2. import { FunctionComponent, InputHTMLAttributes } from "react"
  3. import styles from './forms.module.css';
  4. interface ChipProps extends InputHTMLAttributes<HTMLInputElement> {
  5. label: string,
  6. color?: 'default' | 'primary' | 'secondary'
  7. }
  8. export const Chip: FunctionComponent<ChipProps> = ({ label, color, id, ...props }) => (
  9. <div className={classnames(styles.chip, styles[`${color}Color`])}>
  10. <input type='checkbox' id={id || label} {...props} />
  11. <label htmlFor={id || label}>{label}</label>
  12. </div>
  13. );
  14. Chip.defaultProps = {
  15. color: 'default'
  16. }
  17. export const ChipGroup: FunctionComponent = ({ children }) => (
  18. <div className={styles.chipGroup}>
  19. {children}
  20. </div>
  21. );