Number Input
A numeric input with decrease and increase buttons, limits and a step.
NumberInput is new in v0.4. It binds a decimal?, steps it with - and + buttons, and keeps it between Min and Max.
Installation
bash
shellui add number-input
Usage
Basic
Quantity: 1
<div class="space-y-2">
<NumberInput @bind-Value="quantity" />
<p class="text-sm text-muted-foreground">Quantity: @quantity</p>
</div>
@code {
private decimal? quantity = 1;
}Min and max
The buttons disable at the limits, and typed values are clamped.
2 of 8 guests
<div class="space-y-2">
<NumberInput @bind-Value="guests" Min="1" Max="8" />
<p class="text-sm text-muted-foreground">@guests of 8 guests</p>
</div>
@code {
private decimal? guests = 2;
}Step
Step is a decimal, so write fractions with the m suffix.
Opacity: 0.5
<div class="space-y-2">
<NumberInput @bind-Value="opacity" Min="0" Max="1" Step="0.05m" />
<p class="text-sm text-muted-foreground">Opacity: @opacity</p>
</div>
@code {
private decimal? opacity = 0.5m;
}Disabled
<NumberInput Value="3" Disabled="true" />API Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
Value |
decimal? |
null |
The current value; use @bind-Value |
ValueChanged |
EventCallback<decimal?> |
- | Fires when the value changes |
Min |
decimal? |
null |
Lowest allowed value |
Max |
decimal? |
null |
Highest allowed value |
Step |
decimal |
1 |
Amount added or removed by the buttons |
Disabled |
bool |
false |
Disables the input and both buttons |
Class |
string? |
null |
Additional CSS classes |
Accessibility
- A native
<input type="number">withinputmode="decimal", so the arrow keys and mobile number keyboards work - The buttons are labelled "Decrease" and "Increase"