import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import { useState } from 'react'; import { Checkbox } from '../components/ui/checkbox'; const meta = { title: 'UI/Checkbox', component: Checkbox, parameters: { layout: 'centered', docs: { description: { component: 'A basic checkbox component built on Radix UI primitives. Use for simple boolean selections.', }, }, }, tags: ['autodocs'], argTypes: { checked: { control: 'boolean', description: 'Controlled checked state', }, defaultChecked: { control: 'boolean', description: 'Default checked state for uncontrolled usage', }, disabled: { control: 'boolean', description: 'Whether the checkbox is disabled', }, onCheckedChange: { action: 'checkedChange', description: 'Callback when checked state changes', }, }, } satisfies Meta; export default meta; type Story = StoryObj; /** * Default unchecked checkbox. */ export const Default: Story = { args: {}, }; /** * Checkbox in checked state. */ export const Checked: Story = { args: { defaultChecked: true, }, }; /** * Disabled checkbox. */ export const Disabled: Story = { args: { disabled: true, }, }; /** * Disabled and checked checkbox. */ export const DisabledChecked: Story = { args: { disabled: true, defaultChecked: true, }, }; /** * Checkbox with an associated label using htmlFor. */ export const WithLabel: Story = { args: {}, render: (args) => (
), }; /** * Controlled checkbox with state management. */ export const Controlled: Story = { args: {}, render: function ControlledCheckbox() { const [checked, setChecked] = useState(false); return (
setChecked(value === true)} />
Checked: {checked ? 'true' : 'false'}
); }, }; /** * Multiple checkboxes in a group. */ export const CheckboxGroup: Story = { args: {}, render: () => (
), }; /** * All checkbox states displayed together. */ export const AllVariants: Story = { args: {}, render: () => (
), };