Skip to Content
πŸŽ‰ Coral x Panda has been released πŸŽ‰ Read the Migration Guide
DocumentationFormikFormikTextField

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

NameTypeDefault
disabledboolean

If true, the component will be disabled and not respond to user interactions.

false
disableScrollboolean

Should the field blur on wheel events, to prevent an input change? This is useful for number fields.

false
endIconReactNode

The icon displayed at the end of the TextField.

idstring

The id of the input element. If unspecified, an id will be generated internally.

inputPropsOmit<InputHTMLAttributes<HTMLInputElement>, "className" | "style">

Additional props to be passed directly to the input element, e.g. pattern.

labelstring

The accessible label for the text field.

namestring

The field name used on the POST request when the form is submitted.

onBlurFocusEventHandler<HTMLInputElement>

Callback fired when the text field loses user focus.

onChangeChangeEventHandler<HTMLInputElement>

Callback fired each time the user types in the text field.

onFocusFocusEventHandler<HTMLInputElement>

Callback fired when the text field receives user focus.

minstring | number | undefined

The min attribute specifies the minimum value for a number field.

maxstring | number | undefined

The max attribute specifies the maximum value for a number field.

placeholderstring

Optionally displays a text hint in the field, before it is populated.

optionalboolean

Add 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
startIconReactNode

The icon displayed at the start of the TextField.

stepstring | number | undefined

The step attribute specifies the interval between legal numbers in an input element. For example, if step="3", legal numbers could be -3, 0, 3, 6, etc.

typeHTMLInputTypeAttribute

The HTML input type of this text field.

text
themeResponsiveVariant<ConditionalValue<"secondary500" | "base100"> | undefined>

The colourway applied to this component.

base100
autocompleteAutoFill

The 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
attributesAttributes

This prop can be used to pass HTML attributes directly to the component. We currently allow passing data-* and aria-* attributes and the id. However, you can pass anything else with a type hack if necessary since this object is despread in to the component, without filtering its content.

Example usage:

AttributesProps: { 'id': 'close-button', 'aria-label': 'Close button', 'data-testid': 'close-button' };
validateFieldValidator | undefined

An optional field level validation function. See Formik docsΒ  for more details

refRef<HTMLInputElement> | undefined

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

keyKey | null | undefined
Last updated on