# TextField

## Overview

Text inputs enable the user to interact with and input content and data. This component can be used for long and short form entries.

<figure><img src="https://2985180403-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhSQqKqKx7I7rVBbqF_%2Fuploads%2FvjIsnK6APsujWE6dkrJx%2Ftextfield.png?alt=media&#x26;token=997d67c7-e971-4316-87a3-a21a992f9a3b" alt=""><figcaption></figcaption></figure>

### Widget API

The `CTextField` widget parameters are identical to the normal `TextField` widget, however, it also has some extra parameters:

| Property    | Description                                                                                                                                                                                      |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| enable      | <p>Whether the text field is enabled or not.</p><ul><li><strong>Type:</strong> <code>bool</code></li><li><strong>Default:</strong> <code>true</code></li></ul>                                   |
| label       | <p>An optional text that describes the input field.</p><ul><li><strong>Type:</strong> <code>String?</code></li><li><strong>Default:</strong> optional</li></ul>                                  |
| description | <p>A text that provides context about the value, such as how the value will be used.</p><ul><li><strong>Type:</strong> <code>String?</code></li><li><strong>Default:</strong> optional</li></ul> |
| validator   | <p>An optional method that validates an input.</p><ul><li><strong>Type:</strong> <code>CValidationResult? Function(String? value)?</code></li><li><strong>Default:</strong> optional</li></ul>   |
| isRequired  | <p>If required, the text field label will be followed by red \* .</p><ul><li><strong>Type:</strong> <code>bool</code></li><li><strong>Default:</strong> <code>false</code></li></ul>             |

### Example

```dart
CTextField(
  label: 'Label',
  description: 'Description',
  validator: (value) {
    // OR return null
    return CValidationResult(
        kind: CValidationKind.warning,
        message: 'Your input is missing something.',
    );
  },
);
```
