The Number component provides a specialized input field for numeric values with features such as step controls, range limits, and various display options.
use TallStackUIFilament\Forms\Components\Number;
Number::make('quantity')
->label('Quantity'),Limit the range of allowed values:
Number::make('age')
->minValue(18)
->maxValue(100),
Number::make('rating')
->minValue(1)
->maxValue(5),You can use closures for dynamic values:
Number::make('quantity')
->minValue(fn () => 1)
->maxValue(fn () => $this->record->max_stock ?? 100),Control the increment/decrement step size:
Number::make('temperature')
->step(0.5), // Will increment/decrement by 0.5
Number::make('quantity')
->step(5), // Will increment/decrement by 5Center the input value within the field:
Number::make('rating')
->centralized(), // Centers the value in the input fieldEnable chevron (up/down arrow) controls for incrementing/decrementing:
Number::make('quantity')
->chevron(), // Shows up/down controlsMake the number input selectable:
Number::make('level')
->selectable(), // Makes the number input selectableAdd a placeholder to guide users:
Number::make('weight')
->placeholder('Enter weight in kg...'),use TallStackUIFilament\Forms\Components\Number;
Number::make('quantity')
->label('Product Quantity')
->minValue(1)
->maxValue(100)
->step(1)
->chevron()
->centralized()
->placeholder('Qty')
->selectable()
->required(),The minValue() and maxValue() methods automatically add validation rules. You can add additional validation as needed:
Number::make('even_number')
->minValue(2)
->maxValue(100)
->step(2)
->rules(['integer', 'multiple_of:2']),
Number::make('price')
->minValue(0)
->required()
->numeric(),Add custom HTML attributes to the input element:
Number::make('quantity')
->extraInputAttributes([
'data-analytics-id' => 'quantity-field',
'autocomplete' => 'off',
]),