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

# Input Group

Input Group 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 InputGroup from "@rightui/ui"
```

## Usage

Import 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, InputGroup from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiWeights: FontWeights
    uiFont: string
  derive narrow = width < 600
  state message = ""
  action editMessage(value: string)
    message = value
  state activated = false
  action showToast
    activated = not activated
  view
    column gap="ui.space-16" min-width=0 max-width="100%"
      InputGroup(id="controls-search", label="Search", value=message, placeholder="Search…", prefix="https://", suffix=".com", buttonLabel="Submit", disabled=false, edit=editMessage, submit=showToast)
      if activated
        text ("Search submitted: " + message) testId="input-group-result" role="status" font-size="ui.text-sm" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      text "Prefix only" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      InputGroup(id="input-group-prefix-only", label="Prefix only", value=message, placeholder="example", prefix="https://", suffix="", buttonLabel="", disabled=false, edit=editMessage, submit=showToast)
      text "Suffix only" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      InputGroup(id="input-group-suffix-only", label="Suffix only", value=message, placeholder="example", prefix="", suffix=".com", buttonLabel="", disabled=false, edit=editMessage, submit=showToast)
      text "Disabled" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      InputGroup(id="input-group-disabled", label="Disabled", value=message, placeholder="example", prefix="https://", suffix=".com", buttonLabel="", disabled=true, edit=editMessage, submit=showToast)

```

## 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 |

## Source

File: packages/ui/input-group.contract

```contract
use FieldFocus from "./styles.contract"
use FontWeights from "./typography-context.contract"
use uiFontFamily from "./typography-context.contract"
use ButtonContent from "./button.contract"
component InputGroup
  props
    id: string
    label: string
    value: string
    placeholder: string
    prefix: string
    suffix: string
    buttonLabel: string
    disabled: bool
    edit: action
    submit: action
  inject
    uiWeights: FontWeights
    uiFont: string
  view
    column gap="ui.space-8" min-width="0px"
      text label id=(id + "-label") font-size="ui.text-sm" font-weight=uiWeights.medium color="ui.foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      row id=(id + "-group") testId=(id + "-group") role="group" aria-labelledby=(id + "-label") align-items="center" gap="ui.space-8"
        min-height="ui.space-36" padding="0px ui.space-6 0px ui.space-12" box-sizing="border-box" border-width="ui.border-width" border-style="solid" border-color="ui.border" border-radius="ui.radius-control" background-color="ui.surface" color="ui.foreground"
        if prefix != ""
          text prefix font-size="ui.text-sm" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        input class=FieldFocus id=id testId=id value=value input=edit submit=submit placeholder=placeholder disabled=disabled aria-labelledby=(id + "-label") font-family=uiFontFamily(uiFont) data-rightui-font="body"
          appearance="none" flex=1 min-width="0px" height="ui.space-34" padding="0px" border="0" background-color="transparent" color="ui.foreground" font-size="ui.text-sm"
        if suffix != ""
          text suffix font-size="ui.text-sm" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        if buttonLabel != ""
          ButtonContent(id=id + "-action", label=buttonLabel, variant="secondary", size="xs", disabled=disabled, press=submit)
            text buttonLabel font-family=uiFontFamily(uiFont) data-rightui-font="body"

```
