Skip to content

Commit

Permalink
fix(forms/FormikNumberField): add missing example for number field va…
Browse files Browse the repository at this point in the history
…lidation
  • Loading branch information
sjschlapbach committed Jul 15, 2024
1 parent f962654 commit fd9d457
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/forms/FormikNumberField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,45 @@ export const Default = () => (
</div>
)

export const MinMax = () => (
<div>
<div>
Specifying minimum and maximum values will enable additional validation
steps. In this case, values between 0 and 1000 will be accepted
</div>
<Formik
initialValues={{
name: undefined,
}}
isInitialValid={false}
onSubmit={async (values, { resetForm }) => {
alert(`Form submitted with value: ${values.name}`)
resetForm()
}}
>
{({ values }) => {
return (
<div>
<Form>
<FormikNumberField
name="name"
label="Label"
tooltip="Tooltip for this input"
className={{ root: 'mb-1' }}
placeholder="Placeholder"
min={0}
max={1000}
/>
<Button type="submit">Submit</Button>
</Form>
<div>Value: {values.name}</div>
</div>
)
}}
</Formik>
</div>
)

export const Disabled = () => (
<div>
<div>
Expand Down

0 comments on commit fd9d457

Please sign in to comment.