FormikTextArea
Basic Usage
import { FormikTextArea } from '@krakentech/coral-formik';
import { Button } from '@krakentech/coral';
import { Formik, Form } from 'formik';
<Formik
initialValues={{ textarea: '' }}
onSubmit={() => console.log('Submitted')}
validationSchema={yup.object().shape({
textarea: yup.string().required('This field is required'),
})}
>
<Form method="post">
<FormikTextArea name="textarea" label="Textarea" />
<Button type="submit">Submit</Button>
</Form>
</Formik>Full API
| Name | Type | Default |
|---|---|---|
disabled | booleanIf | false |
id | stringThe id of the input element. If unspecified, an id will be generated internally. | |
label | stringThe accessible label for the text area. | |
name | stringThe field name used on the POST request when the form is submitted. | |
onBlur | FocusEventHandler<HTMLTextAreaElement>Callback fired when the text area loses user focus. | |
onChange | ChangeEventHandler<HTMLTextAreaElement>Callback fired each time the user types in the text area. | |
onFocus | FocusEventHandler<HTMLTextAreaElement>Callback fired when the text area receives user focus. | |
placeholder | stringOptionally displays a text hint in the field, before it is populated. | |
optional | booleanAdd an optional flag to the label for this field (controlled by https://coral-oe.vercel.app/?path=/docs/guides-configuration—docs#overrides-optional-indicator optionalIndicator). This should be set to true if you have set this field to be optional in your validation schema. | false |
rows | numberSpecifies the visible number of lines in a text area. | 3 |
theme | ResponsiveVariant<"base100" | "secondary500">The colourway applied to this component. | base100 |
attributes | AttributesThis prop can be used to pass HTML attributes directly to the component.
We currently allow passing Example usage: | |
validate | FieldValidator | undefinedAn optional field level validation function. See Formik docs for more details | |
ref | Ref<HTMLTextAreaElement> | undefinedAllows getting a ref to the component instance.
Once the component unmounts, React will set | |
key | Key | null | undefined |