ConceptPortal-public/rsconcept/frontend/src/components/Input/Label.tsx
Ivan 536705c00b
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
F: Upgrade to tailwind 4. Fix type imports
2025-02-21 21:15:05 +03:00

33 lines
675 B
TypeScript

import clsx from 'clsx';
import { type Label as LabelStyle } from '../props';
interface LabelProps extends LabelStyle {
/** Text to display. */
text?: string;
}
/**
* Displays a label with optional text.
*
* Note: Html label component is used only if `htmlFor` prop is set.
*/
export function Label({ text, className, ...restProps }: LabelProps) {
if (!text) {
return null;
}
if (restProps.htmlFor) {
return (
<label className={clsx('cc-label', className)} {...restProps}>
{text}
</label>
);
} else {
return (
<span className={clsx('cc-label', className)} {...restProps}>
{text}
</span>
);
}
}