Skip to content

Commit

Permalink
feat: added example for optional field label
Browse files Browse the repository at this point in the history
  • Loading branch information
coderwelsch committed Jun 7, 2024
1 parent 826ef9a commit ae82a7c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/form-field/text-input/text-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ const TextInputWithHooks = ({
hasLeftIcon = false,
readOnly = false,
value,
optional,
}: {
error?: boolean;
disabled?: boolean;
hasLeftIcon?: boolean;
readOnly?: boolean;
value?: string;
optional?: boolean;
}) => {
const [inputValue, setInputValue] = useState(value);

return (
<FormField>
<FormField.LabelGroup>
<FormField.Label htmlFor="value">Label</FormField.Label>
<FormField.Label htmlFor="value" optional={optional}>
Label
</FormField.Label>

<FormField.Description id="value-description">Description</FormField.Description>
</FormField.LabelGroup>

<FormField.TextInput
id="value"
value={inputValue}
Expand All @@ -44,6 +50,7 @@ const TextInputWithHooks = ({
LeftIcon={hasLeftIcon ? SearchIcon : undefined}
readOnly={readOnly}
/>

{error ? <FormField.ErrorMessage>Error message.</FormField.ErrorMessage> : null}
</FormField>
);
Expand Down Expand Up @@ -88,3 +95,11 @@ export const Disabled: Story = {
</div>
),
};

export const Optional: Story = {
render: () => (
<div className="w-72">
<TextInputWithHooks optional />
</div>
),
};

0 comments on commit ae82a7c

Please sign in to comment.