blob: ce4c70f332d749918893596e9e14988f1f130b8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<.field {
width: 100%;
}
.button {
display: block;
margin: auto;
}
ght .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, ReactNode } from 'react';
import styles from './label.module.scss';
export type LabelProps = {
/**
* The label body.
*/
children: ReactNode;
/**
* 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;
|