(feat:components) add label props

This commit is contained in:
ManishMadan2882
2025-01-31 06:23:54 +05:30
parent 4cd2b73f19
commit a69e81076a
2 changed files with 29 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ const Input = ({
value,
isAutoFocused = false,
placeholder,
label,
maxLength,
className,
colorVariant = 'silver',
@@ -26,6 +27,7 @@ const Input = ({
thick: 'border-2',
};
return (
<div className="relative">
<input
className={`h-[42px] w-full rounded-full px-3 py-1 outline-none dark:bg-transparent dark:text-white ${className} ${colorStyles[colorVariant]} ${borderStyles[borderVariant]}`}
type={type}
@@ -41,6 +43,14 @@ const Input = ({
>
{children}
</input>
{label && (
<div className="absolute -top-2 left-2">
<span className="bg-white px-2 text-xs text-gray-4000 dark:bg-outer-space dark:text-silver">
{label}
</span>
</div>
)}
</div>
);
};

View File

@@ -23,9 +23,12 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
}) => {
return (
<label
className={`cursor-pointer select-none items-center ${disabled ? 'opacity-50 cursor-not-allowed' : ''} ${className}`}
className={`cursor-pointer select-none justify-between flex flex-row items-center ${disabled ? 'opacity-50 cursor-not-allowed' : ''} ${className}`}
htmlFor={id}
>
{label && (
<span className="mr-2 text-eerie-black dark:text-white">{label}</span>
)}
<div className="relative">
<input
type="checkbox"
@@ -48,9 +51,6 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
}`}
></div>
</div>
{label && (
<span className="ml-2 text-eerie-black dark:text-white">{label}</span>
)}
</label>
);
};