import type { Meta, StoryObj } from '@storybook/nextjs' import { useState } from 'react' import Radio from '.' const meta = { title: 'Base/Data Entry/Radio', component: Radio, parameters: { layout: 'centered', docs: { description: { component: 'Radio component for single selection. Usually used with Radio.Group for multiple options.', }, }, }, tags: ['autodocs'], argTypes: { checked: { control: 'boolean', description: 'Checked state (for standalone radio)', }, value: { control: 'text', description: 'Value of the radio option', }, disabled: { control: 'boolean', description: 'Disabled state', }, children: { control: 'text', description: 'Label content', }, }, } satisfies Meta export default meta type Story = StoryObj // Single radio demo const SingleRadioDemo = (args: any) => { const [checked, setChecked] = useState(args.checked || false) return (
setChecked(!checked)} > {args.children || 'Radio option'}
) } // Default single radio export const Default: Story = { render: args => , args: { checked: false, disabled: false, children: 'Single radio option', }, } // Checked state export const Checked: Story = { render: args => , args: { checked: true, disabled: false, children: 'Selected option', }, } // Disabled state export const Disabled: Story = { render: args => , args: { checked: false, disabled: true, children: 'Disabled option', }, } // Disabled and checked export const DisabledChecked: Story = { render: args => , args: { checked: true, disabled: true, children: 'Disabled selected option', }, } // Radio Group - Basic const RadioGroupDemo = () => { const [value, setValue] = useState('option1') return (
Option 1 Option 2 Option 3
Selected: {value}
) } export const RadioGroup: Story = { render: () => , } // Radio Group - With descriptions const RadioGroupWithDescriptionsDemo = () => { const [value, setValue] = useState('basic') return (

Select a plan

Basic Plan
Free forever - Perfect for personal use
Pro Plan
$19/month - Advanced features for professionals
Enterprise Plan
Custom pricing - Full features and support
) } export const RadioGroupWithDescriptions: Story = { render: () => , } // Radio Group - With disabled option const RadioGroupWithDisabledDemo = () => { const [value, setValue] = useState('available') return (
Available option Disabled option Another available option
) } export const RadioGroupWithDisabled: Story = { render: () => , } // Radio Group - Vertical layout const VerticalLayoutDemo = () => { const [value, setValue] = useState('email') return (

Notification preferences

Email notifications SMS notifications Push notifications No notifications
) } export const VerticalLayout: Story = { render: () => , } // Real-world example - Settings panel const SettingsPanelDemo = () => { const [theme, setTheme] = useState('light') const [language, setLanguage] = useState('en') return (

Application Settings

Theme

Light mode Dark mode Auto (system preference)

Language

English 中文 (Chinese) Español (Spanish) Français (French)
Current settings: Theme: {theme}, Language: {language}
) } export const SettingsPanel: Story = { render: () => , } // Real-world example - Payment method selector const PaymentMethodSelectorDemo = () => { const [paymentMethod, setPaymentMethod] = useState('credit_card') return (

Payment Method

Credit Card
Visa, Mastercard, Amex
💳
PayPal
Fast and secure
🅿️
Bank Transfer
1-3 business days
🏦
) } export const PaymentMethodSelector: Story = { render: () => , } // Real-world example - Shipping options const ShippingOptionsDemo = () => { const [shipping, setShipping] = useState('standard') const shippingCosts = { standard: 5.99, express: 14.99, overnight: 29.99, } return (

Shipping Method

Standard Shipping
5-7 business days
${shippingCosts.standard}
Express Shipping
2-3 business days
${shippingCosts.express}
Overnight Shipping
Next business day
${shippingCosts.overnight}
Shipping cost: ${shippingCosts[shipping as keyof typeof shippingCosts]}
) } export const ShippingOptions: Story = { render: () => , } // Real-world example - Survey question const SurveyQuestionDemo = () => { const [satisfaction, setSatisfaction] = useState('') return (

Customer Satisfaction Survey

How satisfied are you with our service?

😄 Very satisfied
🙂 Satisfied
😐 Neutral
😟 Dissatisfied
😢 Very dissatisfied
) } export const SurveyQuestion: Story = { render: () => , } // Interactive playground const PlaygroundDemo = () => { const [value, setValue] = useState('option1') return (
Option 1 Option 2 Option 3 Disabled option
Selected: {value}
) } export const Playground: Story = { render: () => , }