diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-08 22:36:24 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-08 23:31:58 +0200 |
| commit | 0b3146f7278929c4d1b33dd8f94f34e351e5e5a9 (patch) | |
| tree | 6a784b197a283a7da07c2e1df80a29fee8b3790a /src/components/atoms/forms/label.tsx | |
| parent | 61278678ea8a8febee0574cd0f6006492d7b15cb (diff) | |
chore: add a Settings modal component
Diffstat (limited to 'src/components/atoms/forms/label.tsx')
| -rw-r--r-- | src/components/atoms/forms/label.tsx | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/components/atoms/forms/label.tsx b/src/components/atoms/forms/label.tsx index 860cd73..8d57ee2 100644 --- a/src/components/atoms/forms/label.tsx +++ b/src/components/atoms/forms/label.tsx @@ -1,9 +1,23 @@ import { FC } from 'react'; -import styles from './forms.module.scss'; +import styles from './label.module.scss'; -type LabelProps = { - htmlFor: string; +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'; }; /** @@ -11,9 +25,17 @@ type LabelProps = { * * Render a HTML label element. */ -const Label: FC<LabelProps> = ({ children, required = false, ...props }) => { +const Label: FC<LabelProps> = ({ + children, + className = '', + required = false, + size = 'small', + ...props +}) => { + const sizeClass = styles[`label--${size}`]; + return ( - <label className={styles.label} {...props}> + <label className={`${styles.label} ${sizeClass} ${className}`} {...props}> {children} {required && <span className={styles.required}> *</span>} </label> |
