Input Group

A text input with a prefix, a suffix, or both.

InputGroup is new in v0.4. It renders an input inside one bordered field with optional Prefix and Suffix slots, for units, protocols, currency symbols or icons.

Installation

bash
shellui add input-group

Usage

Prefix and suffix

https://.com

Value: empty

<div class="w-full max-w-sm space-y-2">
    <InputGroup @bind-Value="website" Placeholder="example">
        <Prefix>https://</Prefix>
        <Suffix>.com</Suffix>
    </InputGroup>
    <p class="text-sm text-muted-foreground">Value: @(string.IsNullOrEmpty(website) ? "empty" : website)</p>
</div>

@code {
    private string? website;
}

Number with units

Type is passed to the <input>, so number, email, search and the other HTML input types work.

$USD
<div class="w-full max-w-sm">
    <InputGroup @bind-Value="price" Type="number" Placeholder="0.00">
        <Prefix>$</Prefix>
        <Suffix>USD</Suffix>
    </InputGroup>
</div>

@code {
    private string? price;
}

Icons and symbols

A slot takes any markup. In Razor, write a literal @ as @@.

@
<div class="w-full max-w-sm space-y-3">
    <InputGroup @bind-Value="query" Type="search" Placeholder="Search components...">
        <Prefix>
            <svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                <path stroke-linecap="round" stroke-linejoin="round" d="m21 21-4.3-4.3M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14Z" />
            </svg>
        </Prefix>
    </InputGroup>

    <InputGroup @bind-Value="handle" Placeholder="username">
        <Prefix>@@</Prefix>
    </InputGroup>
</div>

@code {
    private string? query;
    private string? handle;
}

Disabled

github.com/
<div class="w-full max-w-sm">
    <InputGroup Value="shellui" Disabled="true">
        <Prefix>github.com/</Prefix>
    </InputGroup>
</div>

API Reference

Parameter Type Default Description
Value string? null The input's value; use @bind-Value
ValueChanged EventCallback<string?> - Fires when the value changes
Type string "text" HTML input type
Placeholder string? null Placeholder text
Disabled bool false Disables the input
Prefix RenderFragment? null Content before the input
Suffix RenderFragment? null Content after the input
Class string? null Additional CSS classes

Other attributes, such as id, name or aria-label, are passed to the <input>.

Accessibility

  • The prefix and suffix are plain text next to a native <input>; pair the field with a Label, or pass aria-label
  • The focus ring is drawn around the whole group

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.