File size: 3,292 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
title: Input
description: Used to get user input in a text field.
links:
  source: components/input
  storybook: components-input--basic
  recipe: input
---

<ExampleTabs name="input-basic" />

## Usage

```tsx
import { Input } from "@chakra-ui/react"
```

```tsx
<Input />
```

## Examples

### Variants

Use the `variant` prop to change the visual style of the input.

<ExampleTabs name="input-with-variants" />

### Sizes

Use the `size` prop to change the size of the input.

<ExampleTabs name="input-with-sizes" />

### Helper Text

Pair the input with the `Field` component to add helper text.

<ExampleTabs name="input-with-helper-text" />

### Error Text

Pair the input with the `Field` component to add error text.

<ExampleTabs name="input-with-error-text" />

### Field

Compose the input with the `Field` component to add a label, helper text, and
error text.

<ExampleTabs name="input-with-field" />

### Hook Form

Here's an example of how to integrate the input with `react-hook-form`.

<ExampleTabs name="input-with-hook-form" />

### Element

Use the `startElement` and `endElement` on the `InputGroup` component to add an
element to the start and end of the input.

#### Start Icon

<ExampleTabs name="input-with-start-icon" />

#### Start Text

<ExampleTabs name="input-with-start-text" />

#### Start and End Text

<ExampleTabs name="input-with-start-and-end-text" />

#### Kbd

<ExampleTabs name="input-with-kbd" />

#### Select

<ExampleTabs name="input-with-select" />

### Addon

Use the `InputAddon` and `Group` components to add an addon to the input.

#### Start Addon

<ExampleTabs name="input-with-start-addon" />

#### End Addon

<ExampleTabs name="input-with-end-addon" />

#### Start and End Addon

<ExampleTabs name="input-with-start-and-end-addon" />

### Disabled

Use the `disabled` prop to disable the input.

<ExampleTabs name="input-with-disabled" />

### Button

Use the `Group` component to attach a button to the input.

<ExampleTabs name="input-with-end-button" />

### Focus and Error Color

Use the `--focus-color` and `--error-color` CSS custom properties to change the
color of the input when it is focused or in an error state.

<ExampleTabs name="input-with-focus-error-color" />

### Placeholder Style

Use the `_placeholder` prop to style the placeholder text.

<ExampleTabs name="input-with-placeholder-style" />

### Floating Label

Here's an example of how to build a floating label to the input.

<ExampleTabs name="input-with-floating-label" />

### Mask

Here's an example of using the `use-mask-input` library to mask the input shape.

<ExampleTabs name="input-with-mask" />

### Character Counter

Here's an example of how to add a character counter to the input.

<ExampleTabs name="input-with-character-counter" />

### Card Number

Here's an example of using `react-payment-inputs` to create a card number input.

<ExampleTabs name="input-with-card-number" />

You can create a full card inputs for a card number, expiry date, and CVC.

<ExampleTabs name="input-with-card-details" />

### Clear Button

Combine the `Input` and `CloseButton` components to create a clear button. This
is useful for building search inputs.

<ExampleTabs name="input-with-clear-button" />

## Props

<PropTable component="Input" part="Input" />