switch/01-basic-switch
Switch paired with a label in a horizontal form row.
Loading interactive preview
"use client";
import { useState } from 'react';
import { Switch } from 'ui-lab-components/switch';
export const metadata = {
title: 'Inline Form Field',
description: 'Switch paired with a label in a horizontal form row.',
access: 'free' as const,
};
export default function Example() {
const [enabled, setEnabled] = useState(false);
return (
<div className="flex items-center justify-between gap-4 w-64">
<label htmlFor="marketing" className="text-sm">
Marketing emails
</label>
<Switch
id="marketing"
aria-label="Marketing emails"
isSelected={enabled}
onChange={setEnabled}
/>
</div>
);
}