# Input

> Cherry Input component - text fields, checkboxes, and radio buttons with validation states.

Source: https://cherry.al/code/input

> For the complete documentation index, see [llms.txt](https://cherry.al/llms.txt).

# Input

<iframe className="light-only" src="https://demo.cherry.al/preview/input?theme=light" title="Input" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />
<iframe className="dark-only" src="https://demo.cherry.al/preview/input?theme=dark" title="Input" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />

The Input component encompasses various text input types, including radio buttons and checkboxes. Inputs can have error or success states to provide feedback to the user. Disabled inputs also get dedicated styling with a `not-allowed` cursor and grayed-out colors, and a disabled checkbox renders a dot instead of the check icon when checked.

Keep in mind that the `<input>` element inherently includes native browser properties like `onChange`. Cherry UI components introduce custom properties that always begin with a `$` to distinguish them from native props.

For design guidelines and all interactive states, see the [Inputs](/inputs) design page.

```jsx
import React from "react";
import { Input } from "cherry-styled-components";

export default function Page() {
  return <Input type="text" placeholder="Placeholder" />;
}
```

You can add a label with the `$label` prop:

```html
<Input type="text" $label="Username" $fullWidth />
```

Checkbox and radio examples:

```html
<Input type="checkbox" defaultChecked />
<Input type="radio" />
```

## Properties

<Field value="type" type="string">
  The type of input element. Accepts any native input type, such as `"text"`, `"email"`, `"checkbox"`, or `"radio"`. Date and time types (`"date"`, `"datetime-local"`, `"month"`, `"week"`, `"time"`) automatically render a calendar icon inside the field.
</Field>

<Field value="$label" type="string">
  Label text. For text-like types the label sits inline before the input and stacks above it when the wrapper wraps, for example with `$fullWidth`; rendered after the control for `checkbox` and `radio`.
</Field>

<Field value="$wrapperClassName" type="string">
  Class name applied to the wrapper element around the input, for restyling from the outside.
</Field>

<Field value="$size" type='"default" | "big" | "small"'>
  Size of the input.
</Field>

<Field value="$error" type="boolean">
  Shows error state styling. Also sets `aria-invalid` on the input element automatically.
</Field>

<Field value="$success" type="boolean">
  Shows success state styling.
</Field>

<Field value="$fullWidth" type="boolean">
  Makes the input span the full width of its container.
</Field>

<Field value="$icon" type="React.ReactNode">
  Icon element rendered inside the input.
</Field>

<Field value="$iconPosition" type='"left" | "right"'>
  Position of the icon relative to the input.
</Field>

## Building blocks

Besides the `Input` component itself, the module exports a few pieces for composing custom fields:

- `InputProps` is the TypeScript interface for all Input props, extending the native `<input>` attributes.
- `StyledInputWrapper` is the flex wrapper element rendered around the label and input.
- `StyledLabel` is the styled `<label>` element used to render the `$label` text.

<Button href="https://github.com/cherry-design-system/styled-components/blob/main/src/lib/input.tsx" icon="code" iconPosition="left">
  View Source
</Button>
