forked from rajun/ar-test
feat: add labelled switch row
This commit is contained in:
parent
c0477c3f5a
commit
017933ddd2
27
app/components/ui/switch-row.tsx
Normal file
27
app/components/ui/switch-row.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user