---
name: TextInputField
menu: Components
---

import PropsTable from 'website-src/components/PropsTable'
import { livePreviewStyle } from '../helpers/constants'
import TextInputField from './TextInputField'
import cactusTheme from '@repay/cactus-theme'
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live'

# TextInputField

The `TextInputField` is a combination of `TextInput`, `Label`, and some handy tools to make integrating this field into a form easier.

### Try it out

export const code = `<TextInputField name="input" label="Input" />`

<LiveProvider code={code} scope={{ TextInputField }}>
  <LiveEditor style={livePreviewStyle} />
  <LiveError />
  <LivePreview />
</LiveProvider>

## Best practices

- Use descriptive labels for the input field.
- Be descriptive with the tooltip, if necessary.
- Make use of the `success`, `warning`, and `error` message props when appropriate to make the validity of inputs obvious to the user.

## Basic usage

```jsx
import React, { useState } from 'react'
import { Button, TextInputField } from '@repay/cactus-web'

export default function Form() {
  const [values, setValues] = useState({ input: '' })
  const handleChange = useCallback(
    (e) => {
      setValues(state => ({ ...state, [e.target.name]: e.target.value }))
    },
    [setValues]
  )
  const onSubmit = useCallback(
    event => {
      event.preventDefault()
      const data = { ...values }
      // send data to api
    },
    [values]
  )

  return (
    <form onSubmit={onSubmit}>
      <TextInputField name="input" label="Input" onChange={handleChange} value={values.input} />
      <Button type="submit" variant="action">
        Submit
      </Button>
    </form>
  )
}
```

## Properties

<PropsTable of={TextInputField} />
