> ## Documentation Index
> Fetch the complete documentation index at: https://araf.badr.co.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Input

> A single-line text field for user data entry — supports labels, icons, helper text, and four validation states.

## Overview

<div style={{display:"flex",gap:"24px",flexWrap:"wrap",padding:"28px 24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb",alignItems:"flex-start"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <label style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Email address</label>
    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"9px 13px",fontSize:"14px",color:"#667085",fontFamily:"Inter,sans-serif",background:"#fff",width:"200px"}}>[you@example.com](mailto:you@example.com)</div>
    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Default</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <label style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Email address</label>
    <div style={{border:"1px solid #0479CE",borderRadius:"8px",padding:"9px 13px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"200px",boxShadow:"0 0 0 4px #CDE4F5"}}>[you@email.com](mailto:you@email.com)</div>
    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Focus</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <label style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Email address</label>
    <div style={{border:"1px solid #DC2626",borderRadius:"8px",padding:"9px 13px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"200px"}}>invalid-email</div>
    <span style={{fontSize:"11px",color:"#B42318",fontFamily:"Inter,sans-serif"}}>⚠ Enter a valid email</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <label style={{fontSize:"13px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Username</label>
    <div style={{border:"1px solid #039855",borderRadius:"8px",padding:"9px 13px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"200px"}}>ahmad.dani</div>
    <span style={{fontSize:"11px",color:"#027A48",fontFamily:"Inter,sans-serif"}}>✓ Username available</span>
  </div>
</div>

The **Input** component is the foundational form element for capturing single-line text. It supports labels, placeholder text, leading/trailing icons, helper text, and four validation states.

***

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @araf-ds/core
  ```

  ```bash yarn theme={null}
  yarn add @araf-ds/core
  ```

  ```bash pnpm theme={null}
  pnpm add @araf-ds/core
  ```
</CodeGroup>

***

## Usage

```tsx theme={null}
import { Input } from "@araf-ds/core"

export default function Example() {
  return (
    <Input
      label="Email address"
      placeholder="you@example.com"
      type="email"
    />
  )
}
```

***

## Variants

### Default

The standard input with a label above and optional placeholder.

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px",maxWidth:"320px"}}>
    <label style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Email address</label>
    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#667085",fontFamily:"Inter,sans-serif",background:"#fff"}}>[you@example.com](mailto:you@example.com)</div>
  </div>
</div>

```tsx theme={null}
<Input label="Email address" placeholder="you@example.com" type="email" />
```

### With Helper Text

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px",maxWidth:"320px"}}>
    <label style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Password</label>
    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#667085",fontFamily:"Inter,sans-serif",background:"#fff"}}>••••••••</div>
    <span style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif"}}>Must be at least 8 characters</span>
  </div>
</div>

```tsx theme={null}
<Input
  label="Password"
  type="password"
  helperText="Must be at least 8 characters"
/>
```

### Required Field

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px",maxWidth:"320px"}}>
    <label style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Full name <span style={{color:"#DC2626"}}>\*</span></label>
    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#667085",fontFamily:"Inter,sans-serif",background:"#fff"}}>Enter your full name</div>
  </div>
</div>

```tsx theme={null}
<Input label="Full name" required placeholder="Enter your full name" />
```

### With Leading Icon

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px",maxWidth:"320px"}}>
    <label style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Search</label>

    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#667085",fontFamily:"Inter,sans-serif",background:"#fff",display:"flex",alignItems:"center",gap:"8px"}}>
      <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#9ca3af" strokeWidth="2">
        <circle cx="11" cy="11" r="8" />

        <path d="m21 21-4.35-4.35" />
      </svg>

      Search anything...
    </div>
  </div>
</div>

```tsx theme={null}
<Input
  label="Search"
  placeholder="Search anything..."
  leadingIcon={<SearchIcon size={16} />}
/>
```

***

## States

<div style={{display:"flex",gap:"16px",flexWrap:"wrap",padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb",alignItems:"flex-end"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <div style={{border:"1px solid #D0D5DD",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"160px"}}>Default</div>
    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Default</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <div style={{border:"1px solid #0479CE",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"160px",boxShadow:"0 0 0 4px #CDE4F5"}}>Focused</div>
    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Focus</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <div style={{border:"1px solid #DC2626",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"160px"}}>Error value</div>
    <span style={{fontSize:"11px",color:"#B42318",fontFamily:"Inter,sans-serif"}}>⚠ Error message</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <div style={{border:"1px solid #039855",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#101828",fontFamily:"Inter,sans-serif",background:"#fff",width:"160px"}}>Valid value</div>
    <span style={{fontSize:"11px",color:"#027A48",fontFamily:"Inter,sans-serif"}}>✓ Looks good</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px"}}>
    <div style={{border:"1px solid #E5E7EB",borderRadius:"8px",padding:"10px 14px",fontSize:"14px",color:"#9ca3af",fontFamily:"Inter,sans-serif",background:"#F9FAFB",width:"160px",cursor:"not-allowed"}}>Disabled</div>
    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Disabled</span>
  </div>
</div>

| State    | Border    | Ring          | Helper text color |
| -------- | --------- | ------------- | ----------------- |
| Default  | `#D0D5DD` | —             | `#667085`         |
| Focus    | `#0479CE` | `#CDE4F5` 4px | —                 |
| Error    | `#DC2626` | —             | `#B42318`         |
| Success  | `#039855` | —             | `#027A48`         |
| Disabled | `#E5E7EB` | —             | —                 |

```tsx theme={null}
<Input state="default" />
<Input state="error" helperText="Please enter a valid email" />
<Input state="success" helperText="Username available" />
<Input disabled value="Read-only value" />
```

<Note>
  Avoid hiding inputs when they are unavailable. Use the `disabled` prop so users can still see the field exists.
</Note>

***

## API Reference

<ParamField path="type" type="string" default="text">
  HTML input type. Values: `text` · `email` · `password` · `number` · `search` · `tel` · `url`
</ParamField>

<ParamField path="label" type="string">
  Label displayed above the input field.
</ParamField>

<ParamField path="placeholder" type="string">
  Placeholder text shown when the field is empty.
</ParamField>

<ParamField path="helperText" type="string">
  Helper or error message displayed below the input.
</ParamField>

<ParamField path="state" type="string" default="default">
  Validation state. Values: `default` · `error` · `success` · `disabled`
</ParamField>

<ParamField path="leadingIcon" type="ReactNode">
  Icon rendered inside the input on the left side.
</ParamField>

<ParamField path="trailingIcon" type="ReactNode">
  Icon rendered inside the input on the right side.
</ParamField>

<ParamField path="required" type="boolean" default="false">
  Marks the label with a required asterisk indicator.
</ParamField>

<ParamField path="disabled" type="boolean" default="false">
  Disables the input and applies the disabled visual style.
</ParamField>

<ParamField path="value" type="string">
  Controlled value of the input.
</ParamField>

<ParamField path="onChange" type="(e: ChangeEvent) => void">
  Change event handler.
</ParamField>

<ParamField path="className" type="string">
  Additional Tailwind classes for custom overrides.
</ParamField>

***

## Accessibility

* Input uses native `<input>` element with semantic `<label>` association via `id`/`htmlFor`
* Error messages are linked via `aria-describedby` so screen readers announce them
* Required fields use the `required` HTML attribute in addition to the visual asterisk
* `disabled` inputs carry the native `disabled` attribute — they are excluded from tab order
* Focus ring (`0 0 0 4px #CDE4F5`) meets WCAG 2.1 AA contrast requirements

***

## Do's & Don'ts

<CardGroup cols={2}>
  <Card title="Do" icon="check" iconType="solid" color="#16A34A">
    * Always provide a visible `label` — never rely on placeholder alone
    * Use `helperText` to explain the expected format before the user submits
    * Use `state="error"` with a descriptive `helperText` for inline validation
    * Group related inputs inside a `Form` component for consistent spacing
  </Card>

  <Card title="Don't" icon="xmark" iconType="solid" color="#DC2626">
    * Don't use placeholder text as a substitute for a label
    * Don't show error state until after the user has interacted with the field (avoid premature validation)
    * Don't use custom border colors outside the design system states
    * Don't disable inputs without explaining why — add a tooltip or helper text
  </Card>
</CardGroup>
