Skip to content

Commit 416fdf7

Browse files
committed
Enhance radio group story by wrapping radio options in a flex container for improved alignment with labels
1 parent a442311 commit 416fdf7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

apps/docs/src/remix-hook-form/radio-group.stories.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { zodResolver } from '@hookform/resolvers/zod';
22
import { RadioGroup } from '@lambdacurry/forms/remix-hook-form/radio-group';
33
import { Button } from '@lambdacurry/forms/ui/button';
44
import { FormMessage } from '@lambdacurry/forms/ui/form';
5+
import { Label } from '@lambdacurry/forms/ui/label';
6+
import { RadioGroupItem } from '@lambdacurry/forms/ui/radio-group';
57
import type { Meta, StoryObj } from '@storybook/react';
68
import { expect, userEvent, within } from '@storybook/test';
79
import { type ActionFunctionArgs, Form, useFetcher } from 'react-router';
@@ -56,7 +58,14 @@ const ControlledRadioGroupExample = () => {
5658
<RemixFormProvider {...methods}>
5759
<Form onSubmit={methods.handleSubmit}>
5860
<div className="space-y-4">
59-
<RadioGroup name="size" label="Select a size" options={AVAILABLE_SIZES} />
61+
<RadioGroup name="size" label="Select a size">
62+
{AVAILABLE_SIZES.map((size) => (
63+
<div key={size.value} className="flex items-center space-x-2">
64+
<RadioGroupItem value={size.value} id={size.value} />
65+
<Label htmlFor={size.value}>{size.label}</Label>
66+
</div>
67+
))}
68+
</RadioGroup>
6069
<FormMessage error={methods.formState.errors.size?.message} />
6170
<Button type="submit" className="mt-4">
6271
Submit
@@ -110,7 +119,8 @@ export const Default: Story = {
110119
parameters: {
111120
docs: {
112121
description: {
113-
story: 'A radio group component for selecting a single option from a list.',
122+
story:
123+
'A radio group component for selecting a single option from a list. Each radio option is wrapped in a flex container to align the radio button with its label.',
114124
},
115125
},
116126
},

0 commit comments

Comments
 (0)