barsa b99799c2fe Refactor UI components and enhance styling consistency across the portal
- Updated various components to use consistent color tokens, improving visual coherence.
- Refactored layout components to utilize the new PublicShell for better structure.
- Enhanced error and status messaging styles for improved user feedback.
- Standardized button usage across forms and modals for a unified interaction experience.
- Introduced new UI design tokens and guidelines in documentation to support future development.
2025-12-16 13:54:31 +09:00

53 lines
1.5 KiB
TypeScript

/**
* Checkbox Component
* Basic checkbox input with label support
*/
import React from "react";
import { cn } from "@/lib/utils";
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
label?: string;
error?: string;
helperText?: string;
}
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
({ className, label, error, helperText, id, ...props }, ref) => {
const checkboxId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
return (
<div className="flex flex-col space-y-1">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={checkboxId}
ref={ref}
className={cn(
"h-4 w-4 rounded border-input text-primary focus:ring-ring focus:ring-2",
error && "border-destructive",
className
)}
{...props}
/>
{label && (
<label
htmlFor={checkboxId}
className={cn(
"text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
error && "text-destructive"
)}
>
{label}
</label>
)}
</div>
{helperText && !error && <p className="text-xs text-muted-foreground">{helperText}</p>}
{error && <p className="text-xs text-destructive">{error}</p>}
</div>
);
}
);
Checkbox.displayName = "Checkbox";