GfFormLabel.tsx 590 B

1234567891011121314151617181920212223
  1. import React, { SFC, ReactNode } from 'react';
  2. import classNames from 'classnames';
  3. interface Props {
  4. children: ReactNode;
  5. htmlFor?: string;
  6. className?: string;
  7. isFocused?: boolean;
  8. isInvalid?: boolean;
  9. }
  10. export const GfFormLabel: SFC<Props> = ({ children, isFocused, isInvalid, className, htmlFor, ...rest }) => {
  11. const classes = classNames('gf-form-label', className, {
  12. 'gf-form-label--is-focused': isFocused,
  13. 'gf-form-label--is-invalid': isInvalid,
  14. });
  15. return (
  16. <label className={classes} {...rest} htmlFor={htmlFor}>
  17. {children}
  18. </label>
  19. );
  20. };