mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
36 lines
804 B
TypeScript
36 lines
804 B
TypeScript
import React from 'react';
|
|
import { clsx } from 'clsx';
|
|
|
|
export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
children: React.ReactNode;
|
|
required?: boolean;
|
|
error?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Standalone label component
|
|
*/
|
|
export const Label = React.forwardRef<HTMLLabelElement, LabelProps>(
|
|
({ children, required, error, className, ...props }, ref) => {
|
|
return (
|
|
<label
|
|
ref={ref}
|
|
className={clsx(
|
|
'text-sm font-medium',
|
|
{
|
|
'text-foreground': !error,
|
|
'text-destructive': error,
|
|
"after:content-['*'] after:ml-1 after:text-destructive": required,
|
|
},
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</label>
|
|
);
|
|
}
|
|
);
|
|
Label.displayName = 'Label';
|
|
|