FormikTextField
Basic Usage
import { FormikTextField } from '@krakentech/coral-formik';
import { Button } from '@krakentech/coral';
import { Formik, Form } from 'formik';
<Formik
initialValues={{ textfield: '' }}
onSubmit={() => console.log('Submitted')}
validationSchema={yup.object().shape({
textfield: yup.string().required('This field is required'),
})}
>
<Form method="post">
<FormikTextField name="textfield" label="Textfield" />
<Button type="submit">Submit</Button>
</Form>
</Formik>Full API
| Name | Type | Default |
|---|---|---|
disabled | booleanIf | false |
disableScroll | booleanShould the field blur on wheel events, to prevent an input change? This is useful for number fields. | false |
endIcon | ReactNodeThe icon displayed at the end of the TextField. | |
id | stringThe id of the input element. If unspecified, an id will be generated internally. | |
inputProps | Omit<InputHTMLAttributes<HTMLInputElement>, "className" | "style">Additional props to be passed directly to the input element, e.g. | |
label | stringThe accessible label for the text field. | |
name | stringThe field name used on the POST request when the form is submitted. | |
onBlur | FocusEventHandler<HTMLInputElement>Callback fired when the text field loses user focus. | |
onChange | ChangeEventHandler<HTMLInputElement>Callback fired each time the user types in the text field. | |
onFocus | FocusEventHandler<HTMLInputElement>Callback fired when the text field receives user focus. | |
min | string | number | undefinedThe min attribute specifies the minimum value for a number field. | |
max | string | number | undefinedThe max attribute specifies the maximum value for a number field. | |
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 |
startIcon | ReactNodeThe icon displayed at the start of the TextField. | |
step | string | number | undefinedThe | |
type | HTMLInputTypeAttributeThe HTML input type of this text field. | text |
theme | ResponsiveVariant<ConditionalValue<"secondary500" | "base100"> | undefined>The colourway applied to this component. | base100 |
autocomplete | AutoFillThe HTML autocomplete attribute lets web developers specify what if any permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field. | on |
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<HTMLInputElement> | undefinedAllows getting a ref to the component instance.
Once the component unmounts, React will set | |
key | Key | null | undefined |