2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2023-12-18 19:42:27 +03:00
|
|
|
|
|
|
|
import { CProps } from '../props';
|
2023-08-02 18:24:17 +03:00
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
interface LabelProps extends CProps.Label {
|
|
|
|
text?: string;
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-12-18 19:42:27 +03:00
|
|
|
function Label({ text, className, ...restProps }: LabelProps) {
|
2023-12-15 17:34:50 +03:00
|
|
|
if (!text) {
|
|
|
|
return null;
|
|
|
|
}
|
2024-03-18 16:21:39 +03:00
|
|
|
if (restProps.htmlFor) {
|
|
|
|
return (
|
|
|
|
<label className={clsx('text-sm font-medium whitespace-nowrap', className)} {...restProps}>
|
|
|
|
{text}
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<span className={clsx('text-sm font-medium whitespace-nowrap', className)} {...restProps}>
|
|
|
|
{text}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
export default Label;
|