ConceptPortal-public/rsconcept/frontend/src/components/Common/Label.tsx

22 lines
556 B
TypeScript
Raw Normal View History

import { LabelHTMLAttributes } from 'react';
interface LabelProps
extends Omit<React.DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, 'children'> {
2023-07-15 17:46:19 +03:00
text: string
required?: boolean
}
function Label({ text, required, title, className, ...props }: LabelProps) {
2023-07-15 17:46:19 +03:00
return (
2023-07-25 20:27:29 +03:00
<label
className={`${className} text-sm font-semibold`}
2023-07-15 17:46:19 +03:00
title={ (required && !title) ? 'обязательное поле' : title }
{...props}
>
2023-07-15 17:46:19 +03:00
{text + (required ? '*' : '')}
</label>
);
}
2023-07-25 20:27:29 +03:00
export default Label;