> For the complete documentation index, see [llms.txt](https://jiffyjrdevelopment.gitbook.io/jiffyjrdevelopmentdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jiffyjrdevelopment.gitbook.io/jiffyjrdevelopmentdocs/jiffy-jr-development-docs/jiffy-ui/api/input.md).

# Input

Open a form dialog with one or more fields. The callback receives a key-value table of results, or `nil` if the player cancelled.

## Usage

```lua
exports['jiffy-ui']:Input({
    title  = 'Character Details',
    fields = {
        { type = 'text',     name = 'name',   label = 'Full Name',    required = true },
        { type = 'number',   name = 'age',    label = 'Age',          default = 21    },
        { type = 'textarea', name = 'bio',    label = 'Bio',          placeholder = 'Tell us about yourself...' },
        { type = 'checkbox', name = 'tos',    label = 'Agree to ToS', default = false },
        { type = 'select',   name = 'rank',   label = 'Rank',
          options = { 'Cadet', 'Officer', 'Sergeant' } },
        { type = 'slider',   name = 'volume', label = 'Volume',  min = 0, max = 100, step = 5, default = 75 },
        { type = 'color',    name = 'color',  label = 'Accent',  default = '#4aa3ff' },
    },
}, function(values)
    if not values then return end  -- player cancelled
    print(values.name, values.age, values.color)
end)
```

## Field types

| `type`             | Returns | Notes                                                                  |
| ------------------ | ------- | ---------------------------------------------------------------------- |
| `text`             | string  | Single-line text                                                       |
| `number`           | number  | Numeric input                                                          |
| `textarea`         | string  | Multi-line text                                                        |
| `password`         | string  | Masked input                                                           |
| `checkbox`         | boolean | `true` / `false`                                                       |
| `select`           | string  | Dropdown; `options` is an array of strings or `{ value, label }` pairs |
| `slider` / `range` | number  | Range slider; requires `min`, `max`, `step`                            |
| `color`            | string  | Hex color picker; returns `#rrggbb`                                    |

## Common field properties

| Property      | Description                                                   |
| ------------- | ------------------------------------------------------------- |
| `name`        | Key in the returned values table                              |
| `label`       | Display label shown above the field                           |
| `type`        | Field type (see table above)                                  |
| `default`     | Pre-filled value                                              |
| `placeholder` | Hint text when the field is empty                             |
| `required`    | If `true`, form cannot be submitted while this field is empty |
