# React Form Controls

> React input and textarea components. Give textual form controls like `<input>`s and `<textarea>`s an upgrade with custom styles, sizing, focus states, and more.

## Example

```jsx preview
<CForm>
  <div className="mb-3">
    <CFormLabel htmlFor="exampleFormControlInput1">Email address</CFormLabel>
    
  </div>
  <div className="mb-3">
    <CFormLabel htmlFor="exampleFormControlTextarea1">Example textarea</CFormLabel>
    <CFormTextarea id="exampleFormControlTextarea1" rows={3}></CFormTextarea>
  </div>
</CForm>
```

## Sizing

Set heights using `size` property like `size="lg"` and `size="sm"`.

```jsx preview

```

## Disabled

Add the `disabled` boolean attribute on an input to give it a grayed out appearance and remove pointer events.

```jsx preview

```

## Readonly

Add the `readOnly` boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.

```jsx preview

```

## Readonly plain text

If you want to have `<input readonly>` elements in your form styled as plain text, use the `plainText` boolean property to remove the default form field styling and preserve the correct margin and padding.

```jsx preview
<CRow className="mb-3">
  <CFormLabel htmlFor="staticEmail" className="col-sm-2 col-form-label">Email</CFormLabel>
  <CCol sm={10}>
    
  </CCol>
</CRow>
<CRow className="mb-3">
  <CFormLabel htmlFor="inputPassword" className="col-sm-2 col-form-label">Password</CFormLabel>
  <CCol sm={10}>
    
  </CCol>
</CRow>
```

```jsx preview
<CForm className="row g-3">
  <CCol xs="auto">
    <CFormLabel htmlFor="staticEmail2" className="visually-hidden">Email</CFormLabel>
    
  </CCol>
  <CCol xs="auto">
    <CFormLabel htmlFor="inputPassword2" className="visually-hidden">Password</CFormLabel>
    
  </CCol>
  <CCol xs="auto">
    <CButton color="primary" type="submit" className="mb-3">Confirm identity</CButton>
  </CCol>
</CForm>
```

## File input

```jsx preview
<div className="mb-3">
  <CFormLabel htmlFor="formFile">Default file input example</CFormLabel>
  
</div>
<div className="mb-3">
  <CFormLabel htmlFor="formFileMultiple">Multiple files input example</CFormLabel>
  
</div>
<div className="mb-3">
  <CFormLabel htmlFor="formFileDisabled">Disabled file input example</CFormLabel>
  
</div>
<div className="mb-3">
  <CFormLabel htmlFor="formFileSm">Small file input example</CFormLabel>
  
</div>
<div>
  <CFormLabel htmlFor="formFileLg">Large file input example</CFormLabel>
  
</div>
```

## Color

```jsx preview
<CFormLabel htmlFor="exampleColorInput">Color picker</CFormLabel>

```

## API

### CFormInput

```jsx
import { CFormInput } from '@coreui/react-pro'
```

### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string \| undefined` | - | A string of all className you want applied to the component. |
| `delay` | `number \| boolean \| undefined` | `false` | Delay onChange event while typing. If set to true onChange event will be delayed 500ms, you can also provide the number of milliseconds you want to delay the onChange event. |
| `disabled` | `boolean \| undefined` | - | Toggle the disabled state for the component. |
| `feedback` | `ReactNode` | - | Provide valuable, actionable feedback. |
| `feedbackInvalid` | `ReactNode` | - | Provide valuable, actionable feedback. |
| `feedbackValid` | `ReactNode` | - | Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`. |
| `floatingClassName` | `string \| undefined` | - | A string of all className you want applied to the floating label wrapper. |
| `floatingLabel` | `ReactNode` | - | Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`. |
| `invalid` | `boolean \| undefined` | - | Set component validation state to invalid. |
| `label` | `ReactNode` | - | Add a caption for a component. |
| `onChange` | `ChangeEventHandler<HTMLInputElement> \| undefined` | - | Method called immediately after the `value` prop changes. |
| `plainText` | `boolean \| undefined` | - | Render the component styled as plain text. Removes the default form field styling and preserve the correct margin and padding. Recommend to use only along side `readonly`. |
| `readOnly` | `boolean \| undefined` | - | Toggle the readonly state for the component. |
| `size` | `"sm" \| "lg" \| undefined` | - | Size the component small or large. |
| `text` | `ReactNode` | - | Add helper text to the component. |
| `tooltipFeedback` | `boolean \| undefined` | - | Display validation feedback in a styled tooltip. |
| `type` | `string \| undefined` | `text` | Specifies the type of component. |
| `valid` | `boolean \| undefined` | - | Set component validation state to valid. |
| `value` | `string \| number \| string[] \| undefined` | - | The `value` attribute of component. |

### CFormTextarea

```jsx
import { CFormTextarea } from '@coreui/react-pro'
```

### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string \| undefined` | - | A string of all className you want applied to the component. |
| `disabled` | `boolean \| undefined` | - | Toggle the disabled state for the component. |
| `feedback` | `ReactNode` | - | Provide valuable, actionable feedback. |
| `feedbackInvalid` | `ReactNode` | - | Provide valuable, actionable feedback. |
| `feedbackValid` | `ReactNode` | - | Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`. |
| `floatingClassName` | `string \| undefined` | - | A string of all className you want applied to the floating label wrapper. |
| `floatingLabel` | `ReactNode` | - | Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`. |
| `invalid` | `boolean \| undefined` | - | Set component validation state to invalid. |
| `label` | `ReactNode` | - | Add a caption for a component. |
| `onChange` | `ChangeEventHandler<HTMLTextAreaElement> \| undefined` | - | Method called immediately after the `value` prop changes. |
| `plainText` | `boolean \| undefined` | - | Render the component styled as plain text. Removes the default form field styling and preserve the correct margin and padding. Recommend to use only along side `readonly`. |
| `readOnly` | `boolean \| undefined` | - | Toggle the readonly state for the component. |
| `text` | `ReactNode` | - | Add helper text to the component. |
| `tooltipFeedback` | `boolean \| undefined` | - | Display validation feedback in a styled tooltip. |
| `valid` | `boolean \| undefined` | - | Set component validation state to valid. |
| `value` | `string \| number \| string[] \| undefined` | - | The `value` attribute of component. |
