|
|
|
|
|
title: Input |
|
|
description: Used to get user input in a text field. |
|
|
links: |
|
|
source: components/input |
|
|
storybook: components-input |
|
|
recipe: input |
|
|
|
|
|
|
|
|
<ExampleTabs name="input-basic" /> |
|
|
|
|
|
|
|
|
|
|
|
```tsx |
|
|
import { Input } from "@chakra-ui/react" |
|
|
``` |
|
|
|
|
|
```tsx |
|
|
<Input /> |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Use the `variant` prop to change the visual style of the input. |
|
|
|
|
|
<ExampleTabs name="input-with-variants" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `size` prop to change the size of the input. |
|
|
|
|
|
<ExampleTabs name="input-with-sizes" /> |
|
|
|
|
|
|
|
|
|
|
|
Pair the input with the `Field` component to add helper text. |
|
|
|
|
|
<ExampleTabs name="input-with-helper-text" /> |
|
|
|
|
|
|
|
|
|
|
|
Pair the input with the `Field` component to add error text. |
|
|
|
|
|
<ExampleTabs name="input-with-error-text" /> |
|
|
|
|
|
|
|
|
|
|
|
Compose the input with the `Field` component to add a label, helper text, and |
|
|
error text. |
|
|
|
|
|
<ExampleTabs name="input-with-field" /> |
|
|
|
|
|
|
|
|
|
|
|
Here's an example of how to integrate the input with `react-hook-form`. |
|
|
|
|
|
<ExampleTabs name="input-with-hook-form" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `startElement` and `endElement` on the `InputGroup` component to add an |
|
|
element to the start and end of the input. |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-start-icon" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-start-text" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-start-and-end-text" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-kbd" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-select" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `InputAddon` and `Group` components to add an addon to the input. |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-start-addon" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-end-addon" /> |
|
|
|
|
|
|
|
|
|
|
|
<ExampleTabs name="input-with-start-and-end-addon" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `disabled` prop to disable the input. |
|
|
|
|
|
<ExampleTabs name="input-with-disabled" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `Group` component to attach a button to the input. |
|
|
|
|
|
<ExampleTabs name="input-with-end-button" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the ` |
|
|
color of the input when it is focused or in an error state. |
|
|
|
|
|
<ExampleTabs name="input-with-focus-error-color" /> |
|
|
|
|
|
|
|
|
|
|
|
Use the `_placeholder` prop to style the placeholder text. |
|
|
|
|
|
<ExampleTabs name="input-with-placeholder-style" /> |
|
|
|
|
|
|
|
|
|
|
|
Here's an example of how to build a floating label to the input. |
|
|
|
|
|
<ExampleTabs name="input-with-floating-label" /> |
|
|
|
|
|
|
|
|
|
|
|
Here's an example of using the `use-mask-input` library to mask the input shape. |
|
|
|
|
|
<ExampleTabs name="input-with-mask" /> |
|
|
|
|
|
|
|
|
|
|
|
Here's an example of how to add a character counter to the input. |
|
|
|
|
|
<ExampleTabs name="input-with-character-counter" /> |
|
|
|
|
|
|
|
|
|
|
|
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" /> |
|
|
|
|
|
|
|
|
|
|
|
Combine the `Input` and `CloseButton` components to create a clear button. This |
|
|
is useful for building search inputs. |
|
|
|
|
|
<ExampleTabs name="input-with-clear-button" /> |
|
|
|
|
|
|
|
|
|
|
|
<PropTable component="Input" part="Input" /> |
|
|
|