Typed Select

Native select bound to a typed value: enums, numbers, Guids, bools or strings

TypedSelect<TValue> is a styled native <select> whose value is a real type instead of a string. The selected <option value="..."> is parsed into TValue: enums, int and other numbers, Guid, bool, and string are supported, including nullable versions.

Installation

bash
shellui add typed-select

Usage

Selected:

<div class="w-full max-w-sm">
  <TypedSelect TValue="Priority?" @bind-Value="_priority">
      <option value="">Choose a priority</option>
      <option value="Low">Low</option>
      <option value="Medium">Medium</option>
      <option value="High">High</option>
  </TypedSelect>

  <p>Selected: @_priority</p>
</div>

@code {
    private Priority? _priority;

    enum Priority { Low, Medium, High }
}

An empty value="" option maps to null for nullable types.

Numeric values

<div class="w-full max-w-sm">
  <TypedSelect TValue="int" @bind-Value="_pageSize">
      <option value="10">10 per page</option>
      <option value="25">25 per page</option>
      <option value="50">50 per page</option>
  </TypedSelect>
</div>

@code {
    private int _pageSize = 25;
}

API Reference

Property Type Default Description
TValue Generic type — The value type
Value TValue? default Selected value (supports @bind-Value)
ValueChanged EventCallback<TValue?> — Raised when the selection changes
ChildContent RenderFragment? null The <option> elements
Disabled bool false Disables the select
Class string? null Additional CSS classes

Other attributes are passed to the <select> element.

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.