---
title: "Input"
description: "Input with accessible presentation and local state."
---

# Input

Input with accessible presentation and local state.

## Installation

Install the shared package once in your Exact app. This version is a beta.

```sh
bun add --exact @rightui/ui@0.4.0-beta.4
```

Or choose another package manager:

```sh
npm install --save-exact @rightui/ui@0.4.0-beta.4
pnpm add --save-exact @rightui/ui@0.4.0-beta.4
yarn add --exact @rightui/ui@0.4.0-beta.4
```

Exact compilation uses Bun 1.4.2. Register Geist and Newsreader, declare the font marker and add the root provider using [Installation](/docs/installation).

### Manual source setup

Install an editable copy of the complete package:

```sh
mkdir -p vendor/rightui vendor/rightui-ui
npm pack @rightui/ui@0.4.0-beta.4 --pack-destination vendor/rightui
tar -xzf ./vendor/rightui/rightui-ui-0.4.0-beta.4.tgz -C vendor/rightui-ui --strip-components=1
bun add file:./vendor/rightui-ui
```

Keep package.json, the Contract files, ui.tamber, assets and licenses together.

### Import

```contract
use Input, InputGroup, InputOTP from "@rightui/ui"
```

## Usage

Import Input, InputGroup from @rightui/ui. Store its value in state and update it through the provided action callback.

## Example

```contract
use FontWeights from "@rightui/ui"
use uiFontFamily, FieldGroup, Button from "@rightui/ui"
use Input from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiWeights: FontWeights
    uiFont: string
  derive narrow = width < 600
  state folder = "Editing"
  action editFolder(v: string)
    folder = v
  state savedFolder = false
  action saveFolder
    savedFolder = true
  view
    column gap="ui.space-16" min-width=0 max-width="100%"
      Input(id="catalog-folder", label="Folder name", value=folder, placeholder="Your folder", error="", disabled=false, edit=editFolder)
      Input(id="catalog-input-invalid", label="Invalid input", value=folder, placeholder="Required", error="This field is required.", disabled=false, edit=editFolder)
      Input(id="catalog-input-disabled", label="Disabled input", value="Read only preview", placeholder="", error="", disabled=true, edit=editFolder)
      text "Grouped inline fields and action" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      FieldGroup(id="input-inline-group", nested=false)
        row gap="ui.space-12" flex-wrap="wrap"
          Input(id="input-inline-name", label="Folder", value=folder, placeholder="Folder", error="", disabled=false, edit=editFolder)
          Button(id="input-inline-save", label="Save folder", variant="outline", disabled=false, press=saveFolder)
        text (savedFolder ? "Folder saved locally." : "Edit a folder name.") role="status" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```

## API Reference

| Property | Type |
| --- | --- |
| InputGroup.id | string |
| InputGroup.label | string |
| InputGroup.value | string |
| InputGroup.placeholder | string |
| InputGroup.prefix | string |
| InputGroup.suffix | string |
| InputGroup.buttonLabel | string |
| InputGroup.disabled | bool |
| InputGroup.edit | action |
| InputGroup.submit | action |
| InputOTP.id | string |
| InputOTP.label | string |
| InputOTP.value | string |
| InputOTP.length | number |
| InputOTP.disabled | bool |
| InputOTP.change | action |
| Input.id | string |
| Input.label | string |
| Input.value | string |
| Input.placeholder | string |
| Input.error | string |
| Input.disabled | bool |
| Input.edit | action |

## Source

File: packages/ui/input.contract

```contract
use FontWeights from "./typography-context.contract"
use uiFontFamily from "./typography-context.contract"
use Field from "./styles.contract"
component Input
  props
    id: string
    label: string
    value: string
    placeholder: string
    error: string
    disabled: bool
    edit: action
  inject
    uiWeights: FontWeights
    uiFont: string
  view
    column gap="ui.space-8" min-width=0
      text label id=(id + "-label") font-size="ui.text-sm" font-weight=uiWeights.medium font-family=uiFontFamily(uiFont) data-rightui-font="body" color="ui.foreground"
      input id=id testId=id class=Field font-weight=uiWeights.regular value=value input=edit placeholder=placeholder disabled=disabled font-family=uiFontFamily(uiFont) data-rightui-font="body"
        aria-labelledby=(id + "-label") aria-invalid=(error != "") aria-describedby=(id + "-hint")
        border-color=(error == "" ? "ui.border" : "ui.danger")
        ::placeholder
          color="ui.muted-foreground"
      text error id=(id + "-hint") font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body" color="ui.danger" display=(error == "" ? "none" : "block")

component InputControl
  props
    id: string
    label: string
    value: string
    placeholder: string
    disabled: bool
    edit: action
  inject
    uiWeights: FontWeights
    uiFont: string
  params
    radius: length = "ui.radius-control" control="token" group="Shape"
    insetX: length = "ui.space-12" control="token" group="Spacing"
    insetY: length = "ui.space-4" control="token" group="Spacing"
  view
    input id=id testId=id class=Field font-weight=uiWeights.regular aria-label=label value=value input=edit placeholder=placeholder disabled=disabled border-radius="param.radius" padding="param.insetY param.insetX" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      ::placeholder
        color="ui.muted-foreground"

```
