Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
Carbon provides inputs which are able to visually indicate three states of validations out of the box.
Each input component which supports validations accepts following props - error
, warning
or info
.
Passing a string
to these props will display a border along with a validation icon and tooltip; this string
value will be displayed as the tooltip message.
Passing a boolean
to these props will display a border and validation icon without the additional tooltip information.
The only exception from this is the DateRange
component which displays separate validation statuses on either start
or end
dates - to achieve this the DateRange
component accepts startError
, endError
, startWarning
, endWarning
, startInfo
and endInfo
props.
Grouping components like RadioButtonGroup
, CheckboxGroup
and ButtonToggleGroup
support validations too.
Passing validation props on a group component will display a validation icon on the group label/legend and apply proper styles to the grouped inputs.
The interface is the same - it's up to the consumer to decide whether to display validation on the group label/legend or on the individual component.
Most of the input components support two variants of validation icon placement:
To decide which placement is preferred validationOnLabel
or validationOnLegend
props can be used.
Carbon provides a Form component which augments an HTML <form>
element with:
For more information check Form in Storybook
Formik keeps track of your form's state, and then exposes it (plus a few reusable methods and event handlers) to your form via props. 🔗
Formik provides a small set of React components and hooks, of which the key ones are:
Note: Formik is only intended to be used with
controlled components, where the component's state is
controlled by supplying a value
prop (or a checked
prop for radio
and checkbox
). Technically it's possible to
use Formik with uncontrolled components (by not supplying a
controlling value
/checked
prop, and only supplying name
onChange
onBlur
props), but this is strongly
discouraged ⚠️
Formik supports three kinds of validation:
values
object is
passed to a validate()
function which implements its own custom validation logic and returns an errors
object.validate()
functions are supplied for each form field.