Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Forms

TwInputGroup

TwInputGroup wraps a Blazor input with text, icons or buttons before, after, above or below it, drawn as a single field.

Last updated 7 November 2026

Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at https://github.com/twblazor/twblazor/issues.

Icons

Put a TwIcon in a TwInputGroupAddon. An addon sits at the start of the input by default; set Align="InputGroupAlign.InlineEnd" to put it at the end. Start and end follow the layout direction, so they swap sides in a right to left layout.
RAZOR
<div class="grid gap-4 sm:grid-cols-2">
    <TwInputGroup Label="Search" For="input-group-search">
        <TwInputGroupAddon>
            <TwIcon Icon="Icon.Search" />
        </TwInputGroupAddon>
        <TwTextfield Id="input-group-search" T="string" InputType="search" Placeholder="Search components" @bind-Value="search" />
    </TwInputGroup>

    <TwInputGroup Label="Email" For="input-group-email">
        <TwTextfield Id="input-group-email" T="string" InputType="email" Placeholder="you@example.com" @bind-Value="email" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwIcon Icon="Icon.Check_Circle" Class="text-green-700 dark:text-green-400" />
        </TwInputGroupAddon>
    </TwInputGroup>
</div>
CSHARP
@code {
    private string search = string.Empty;
    private string email = string.Empty;
}

Text

Use TwInputGroupText for a protocol, a currency symbol or a unit. It is added to the input's aria-describedby, so a screen reader reads it with the field. Use as many addons as you need on either side.
https://
.com
$
USD
RAZOR
<div class="grid gap-4 sm:grid-cols-2">
    <TwInputGroup Label="Website" For="input-group-website">
        <TwInputGroupAddon>
            <TwInputGroupText Text="https://" />
        </TwInputGroupAddon>
        <TwTextfield Id="input-group-website" T="string" Placeholder="example" @bind-Value="website" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwInputGroupText Text=".com" />
        </TwInputGroupAddon>
    </TwInputGroup>

    <TwInputGroup Label="Price" For="input-group-price">
        <TwInputGroupAddon>
            <TwInputGroupText Text="$" />
        </TwInputGroupAddon>
        <TwNumeric Id="input-group-price" T="decimal" Format="N2" Min="0m" HideSpinButtons @bind-Value="price" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwInputGroupText Text="USD" />
        </TwInputGroupAddon>
    </TwInputGroup>
</div>
CSHARP
@code {
    private string website = string.Empty;
    private decimal price = 49.99m;
}

Buttons

TwInputGroupButton is a TwButton sized for the field: a compact ButtonVariant.Text button by default, rounded to follow the field's corners. Give an icon-only button an AriaLabel.
Copy link
RAZOR
<div class="grid gap-4 sm:grid-cols-2">
    <TwInputGroup Label="Subscribe" For="input-group-subscribe">
        <TwTextfield Id="input-group-subscribe" T="string" InputType="email" Placeholder="you@example.com" @bind-Value="subscribeEmail" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwInputGroupButton Label="Subscribe" Variant="ButtonVariant.Filled" Color="Color.Primary" OnClick="Subscribe" />
        </TwInputGroupAddon>
    </TwInputGroup>

    <TwInputGroup Label="Invite link" For="input-group-invite">
        <TwTextfield Id="input-group-invite" T="string" ReadOnly Value="@inviteLink" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwInputGroupButton IconButton StartIcon="@(copied ? Icon.Check : Icon.Copy)" AriaLabel="@(copied ? "Copied" : "Copy link")" Tooltip="@(copied ? "Copied" : "Copy link")" OnClick="CopyLink" />
        </TwInputGroupAddon>
    </TwInputGroup>
</div>
@if (subscribed)
{
    <p class="mt-2 text-sm text-gray-600 dark:text-gray-400" role="status">Subscribed @subscribeEmail.</p>
}
CSHARP
@code {
    private string subscribeEmail = string.Empty;
    private bool subscribed;
    private readonly string inviteLink = "https://example.com/invite/7Q2X9";
    private bool copied;
    
    private void Subscribe() => subscribed = !string.IsNullOrWhiteSpace(subscribeEmail);
    
    private void CopyLink() => copied = true;
}

Password toggle

Combine an icon at the start with a button at the end that switches the field between password and text.
RAZOR
<TwInputGroup Label="Password" For="input-group-password">
    <TwInputGroupAddon>
        <TwIcon Icon="Icon.Lock" />
    </TwInputGroupAddon>
    <TwTextfield Id="input-group-password" T="string" InputType="@(showPassword ? "text" : "password")" Placeholder="Enter your password" @bind-Value="password" />
    <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
        <TwInputGroupButton IconButton StartIcon="@(showPassword ? Icon.Eye_Slash : Icon.Eye)" AriaLabel="@(showPassword ? "Hide password" : "Show password")" aria-pressed="@(showPassword ? "true" : "false")" OnClick="@(() => showPassword = !showPassword)" />
    </TwInputGroupAddon>
</TwInputGroup>
CSHARP
@code {
    private string password = string.Empty;
    private bool showPassword;
}

Multiline text with block addons

Set Align to InputGroupAlign.BlockStart or InputGroupAlign.BlockEnd to put an addon on its own row above or below the input, such as a toolbar, a character counter or a send button for a Multiline text field.
To: design-team
0/280
RAZOR
<TwInputGroup Label="Message" For="input-group-message">
    <TwInputGroupAddon Align="InputGroupAlign.BlockStart" Class="justify-between">
        <TwInputGroupText Text="To: design-team" />
        <TwInputGroupButton IconButton StartIcon="Icon.Paperclip" AriaLabel="Attach a file" />
    </TwInputGroupAddon>
    <TwTextfield Id="input-group-message" T="string" Multiline AutoGrow Rows="3" MaxRows="8" BindEvent="oninput" Placeholder="Write a message" @bind-Value="message" />
    <TwInputGroupAddon Align="InputGroupAlign.BlockEnd" Class="justify-between">
        <TwInputGroupText Text="@($"{message.Length}/280")" DescribesInput="false" aria-live="polite" />
        <TwInputGroupButton Label="Send" EndIcon="Icon.Send" Variant="ButtonVariant.Filled" Color="Color.Primary" Disabled="@(message.Length == 0 || message.Length > 280)" />
    </TwInputGroupAddon>
</TwInputGroup>
CSHARP
@code {
    private string message = string.Empty;
}

Variants

The group draws the field for its Variant - Default, Outlined or Filled - and the input inside takes off its own border, background and rounding. Without a Variant, the group uses the theme's default input variant, the same as the inputs.
RAZOR
<div class="grid gap-4 sm:grid-cols-3">
    <TwInputGroup Label="Default" For="input-group-variant-default" Variant="InputVariant.Default">
        <TwInputGroupAddon><TwIcon Icon="Icon.At" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-variant-default" T="string" Placeholder="username" @bind-Value="username" />
    </TwInputGroup>
    <TwInputGroup Label="Outlined" For="input-group-variant-outlined" Variant="InputVariant.Outlined">
        <TwInputGroupAddon><TwIcon Icon="Icon.At" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-variant-outlined" T="string" Placeholder="username" @bind-Value="username" />
    </TwInputGroup>
    <TwInputGroup Label="Filled" For="input-group-variant-filled" Variant="InputVariant.Filled">
        <TwInputGroupAddon><TwIcon Icon="Icon.At" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-variant-filled" T="string" Placeholder="username" @bind-Value="username" />
    </TwInputGroup>
</div>
CSHARP
@code {
    private string username = string.Empty;
}

Dense

Set Dense on the group for the compact height. The input and the buttons inside it shrink to match, so the group lines up with other dense inputs.
RAZOR
<div class="flex flex-wrap items-end gap-4">
    <TwInputGroup Label="Filter" For="input-group-dense" Dense Class="w-64">
        <TwInputGroupAddon><TwIcon Icon="Icon.Search" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-dense" T="string" Placeholder="Filter rows" @bind-Value="filter" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
            <TwInputGroupButton Label="Apply" />
        </TwInputGroupAddon>
    </TwInputGroup>
    <TwTextfield T="string" Label="Dense text field" Dense Placeholder="For comparison" Class="w-48" @bind-Value="filter" />
</div>
CSHARP
@code {
    private string filter = string.Empty;
}

Other inputs

Any single-line input can go in a group: a TwSelect, a TwMaskedInput, a TwNumeric, a TwAutocomplete or a picker such as TwDatePicker.
kg
RAZOR
<div class="grid gap-4 sm:grid-cols-3">
    <TwInputGroup Label="Country" For="input-group-country">
        <TwInputGroupAddon><TwIcon Icon="Icon.Globe" /></TwInputGroupAddon>
        <TwSelect Id="input-group-country" T="string" Values="@_countries" Placeholder="Choose a country" @bind-SelectedValue="country" />
    </TwInputGroup>
    <TwInputGroup Label="Phone" For="input-group-phone">
        <TwInputGroupAddon><TwIcon Icon="Icon.Telephone" /></TwInputGroupAddon>
        <TwMaskedInput Id="input-group-phone" Mask="(999) 999-9999" @bind-Value="phone" />
    </TwInputGroup>
    <TwInputGroup Label="Weight" For="input-group-weight">
        <TwNumeric Id="input-group-weight" T="int" Min="0" Max="500" @bind-Value="weight" />
        <TwInputGroupAddon Align="InputGroupAlign.InlineEnd"><TwInputGroupText Text="kg" /></TwInputGroupAddon>
    </TwInputGroup>
</div>
CSHARP
@code {
    private string country = string.Empty;
    private string phone = string.Empty;
    private int weight = 70;
    private readonly string[] _countries = ["USA", "Canada", "UK", "Germany", "France", "Japan", "Australia"];
}

Validation and disabled

An invalid input turns the group's border red, and its message is shown below the group rather than inside it, still linked to the input through aria-describedby. A disabled input dims the whole group.
@

Use at least 3 characters.

RAZOR
<div class="grid gap-4 sm:grid-cols-2">
    <TwInputGroup Label="Username" For="input-group-invalid">
        <TwInputGroupAddon><TwInputGroupText Text="@@" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-invalid" T="string" Placeholder="username" BindEvent="oninput" Invalid="@(handle.Length < 3)" ErrorMessage="Use at least 3 characters." @bind-Value="handle" />
    </TwInputGroup>
    <TwInputGroup Label="Disabled" For="input-group-disabled">
        <TwInputGroupAddon><TwIcon Icon="Icon.Lock" /></TwInputGroupAddon>
        <TwTextfield Id="input-group-disabled" T="string" Disabled Value="@("Not editable")" />
    </TwInputGroup>
</div>
CSHARP
@code {
    private string handle = "a";
}

Custom styling

Class styles the group itself and is merged with the theme's classes, so it can replace the rounding or border colour. RootClass styles the element that also holds the label and messages.
RAZOR
<TwInputGroup AriaLabel="Search the docs" Variant="InputVariant.Outlined" Rounded="Rounded.Full" Class="border-purple-600 dark:border-purple-400">
    <TwInputGroupAddon><TwIcon Icon="Icon.Search" /></TwInputGroupAddon>
    <TwTextfield T="string" InputType="search" AriaLabel="Search the docs" Placeholder="Search the docs" @bind-Value="search" />
    <TwInputGroupAddon Align="InputGroupAlign.InlineEnd">
        <TwInputGroupButton Label="Search" Variant="ButtonVariant.Filled" Color="Color.Primary" />
    </TwInputGroupAddon>
</TwInputGroup>

Accessibility

The group is rendered with role="group" and named by its Label (or AriaLabel). Set For to the input's Id so the label names the input too and clicking it focuses the input; otherwise give the input its own AriaLabel. Text in a TwInputGroupText is added to the input's aria-describedby; set DescribesInput="false" for text that adds nothing, such as a live counter. Icons are decorative and hidden from screen readers unless they have an AriaLabel. Addons are placed by Align rather than by their order in the markup, but Tab follows the markup, so write them in the order they appear. The group's focus ring follows the input, while each button in an addon shows its own.

Keyboard navigation

An input group is a group named by its label. It adds no keys of its own: the input and any buttons in its addons keep their usual keys, and Tab moves through them in the order they are written in the markup, so write the addons in the order they appear. Text in an addon is read with the input.
Key What it does
Tab or Shift+ plus Tab Moves focus to the input, then to each button in the addons.
Enter or Space On a button: activates it.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwInputGroupTheme), configured via the AddTwBlazor() options callback described on the Get Started page. Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
Property Type Controls
Root string
Group string
Padding string
DefaultPadding string
FocusBorder string
InvalidBorder string
Disabled string
Control string
ControlRoot string
ControlRootOutlinedOffset string
ControlRootUnderlinedOffset string
Addon string
AddonInlineStart string
AddonInlineEnd string
AddonBlockStart string
AddonBlockEnd string
Text string
Button string
ButtonDense string
IconButtonDense string

Full reference: TwInputGroupTheme on the API docs.

On this page

  • Icons
  • Text
  • Buttons
  • Password toggle
  • Multiline text with block addons
  • Variants
  • Dense
  • Other inputs
  • Validation and disabled
  • Custom styling
  • Accessibility
  • Keyboard navigation
  • Theme configuration
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload