aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/forms/fields/text-area/index.ts
blob: e18b3258aee373bf0b08099e172f230ec3af83e6 (plain)
1
export * from './text-area';
g.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
import { FC } from 'react';
import styles from './label.module.scss';

export type LabelProps = {
  /**
   * Add classnames to the label.
   */
  className?: string;
  /**
   * The field id.
   */
  htmlFor?: string;
  /**
   * Is the field required? Default: false.
   */
  required?: boolean;
  /**
   * The label size. Default: small.
   */
  size?: 'medium' | 'small';
};

/**
 * Label Component
 *
 * Render a HTML label element.
 */
const Label: FC<LabelProps> = ({
  children,
  className = '',
  required = false,
  size = 'small',
  ...props
}) => {
  const sizeClass = styles[`label--${size}`];

  return (
    <label className={`${styles.label} ${sizeClass} ${className}`} {...props}>
      {children}
      {required && <span className={styles.required}> *</span>}
    </label>
  );
};

export default Label;