InputGroup
Data inputA text field with addons inside its box: an icon, a unit or prefix, a button. <InputGroup.Root> holds one control, an InputGroup.Input or InputGroup.Textarea (in a Field, labelled and described by it), and InputGroup.Addons (align: inline-start, inline-end, block-start, block-end) holding icons, InputGroup.Text or InputGroup.Buttons. The group draws the box, its focus ring and its invalid state; clicking an addon's text focuses the control.
import { InputGroup } from '@limerdev/zest'; Input. A choice from a list: use Select or Combobox. An addon that is the only label: give the field a Field.Label or aria-label.Examples
Addons
An icon, a unit, a prefix: addons sit inside the field's box, before or after the input.
<script lang="ts">
import Search from '@lucide/svelte/icons/search';
import { Field, InputGroup } from '@limerdev/zest';
</script>
<div class="flex w-full max-w-sm flex-col gap-4">
<InputGroup.Root>
<InputGroup.Addon><Search /></InputGroup.Addon>
<InputGroup.Input type="search" placeholder="Search customers" aria-label="Search customers" />
</InputGroup.Root>
<Field.Root>
<Field.Label>Amount</Field.Label>
<InputGroup.Root>
<InputGroup.Input type="number" placeholder="0" />
<InputGroup.Addon align="inline-end"><InputGroup.Text>kr</InputGroup.Text></InputGroup.Addon>
</InputGroup.Root>
</Field.Root>
<Field.Root>
<Field.Label>Website</Field.Label>
<InputGroup.Root>
<InputGroup.Addon><InputGroup.Text>https://</InputGroup.Text></InputGroup.Addon>
<InputGroup.Input class="ps-1" placeholder="acme.se" />
</InputGroup.Root>
</Field.Root>
</div> Buttons
Buttons in addons: show a secret, or send a message from under its text area.
<script lang="ts">
import Eye from '@lucide/svelte/icons/eye';
import EyeOff from '@lucide/svelte/icons/eye-off';
import Send from '@lucide/svelte/icons/send';
import { Field, InputGroup } from '@limerdev/zest';
let shown = $state(false);
</script>
<div class="flex w-full max-w-sm flex-col gap-4">
<Field.Root>
<Field.Label>API key</Field.Label>
<InputGroup.Root>
<InputGroup.Input type={shown ? 'text' : 'password'} value="sk_live_51Hx9" readonly />
<InputGroup.Addon align="inline-end">
<InputGroup.Button
size="icon-sm"
aria-label={shown ? 'Hide key' : 'Show key'}
onclick={() => (shown = !shown)}
>
{#if shown}<EyeOff />{:else}<Eye />{/if}
</InputGroup.Button>
</InputGroup.Addon>
</InputGroup.Root>
</Field.Root>
<Field.Root>
<Field.Label>Message</Field.Label>
<InputGroup.Root>
<InputGroup.Textarea placeholder="Write a note to the customer" />
<InputGroup.Addon align="block-end" class="justify-between">
<InputGroup.Text>Sent by email</InputGroup.Text>
<InputGroup.Button variant="primary">Send <Send /></InputGroup.Button>
</InputGroup.Addon>
</InputGroup.Root>
</Field.Root>
</div> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
InputGroup.Root
No props of its own beyond the common ones.
InputGroup.Addon
| Prop | Type | Default | Description |
|---|---|---|---|
| align | "inline-start" | "inline-end" | "block-start" | "block-end" | 'inline-start' | Where it sits: before or after the control on its line (inline-start, inline-end), or above or below it (block-start, block-end). |
InputGroup.Text
No props of its own beyond the common ones.
InputGroup.Input
| Prop | Type | Default | Description |
|---|---|---|---|
| files bindable | FileList | null | – | The chosen files, for type="file". Bindable. |
| value bindable | string | number | null | – | The text, or a number for type="number". Bindable. |
InputGroup.Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
| value bindable | string | null | – | The text. Bindable. |
InputGroup.Button
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | null | false | true | – | |
| href | string | null | – | |
| loading | boolean | false | Waiting for the action it started: a spinner shows (in place of the icon of an icon-size button), it is marked busy and unavailable, and clicks do nothing. Unlike disabled, it keeps keyboard focus. |
| size | "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | 'sm' | The height and padding, from the theme's field size; the icon sizes are square. |
| type | null | "button" | "submit" | "reset" | – | |
| variant | "link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost" | 'ghost' | The look, by the theme's colour roles: primary for the main action, error for deleting, secondary, neutral and outline for the rest, ghost in toolbars, link for a navigation that looks like text. |