28 lines
1001 B
TypeScript
28 lines
1001 B
TypeScript
import { Label } from '~/components/ui/label';
|
|
import { Switch } from '~/components/ui/switch';
|
|
import { Text } from '~/components/ui/text';
|
|
import { cn } from '~/lib/utils';
|
|
|
|
interface SwitchRowProps {
|
|
id: string;
|
|
label: string;
|
|
hint?: string;
|
|
checked: boolean;
|
|
disabled?: boolean;
|
|
framed?: boolean;
|
|
onCheckedChange: (checked: boolean) => void;
|
|
}
|
|
|
|
// A labelled on/off setting
|
|
export function SwitchRow({ id, label, hint, checked, disabled, framed, onCheckedChange }: SwitchRowProps) {
|
|
return (
|
|
<div className={cn('flex items-center justify-between gap-6', framed && 'rounded-control px-3 py-2.5 ring-1 ring-inset ring-border-control')}>
|
|
<div className='flex min-w-0 flex-col gap-0.5'>
|
|
<Label htmlFor={id}>{label}</Label>
|
|
{hint && <Text variant='caption'>{hint}</Text>}
|
|
</div>
|
|
<Switch id={id} checked={checked} disabled={disabled} onCheckedChange={onCheckedChange} />
|
|
</div>
|
|
);
|
|
}
|