Basic Usage
Attributes
The input name attribute. Used for form submission and error handling.
The label text displayed for the input. If empty, a label will be auto-generated from the name.
The model instance to bind to. The component will automatically fetch the value from the model using the name attribute.
The default value if no model value or old input exists.
Whether to display validation errors below the input.
Whether to display the label. Set to
false to hide the label.Custom placeholder text for the input.
Automatically use the label as placeholder text when
true.Mark the input as required. Adds HTML5 required attribute and displays a required indicator on the label.
Display the label and input inline (horizontal layout).
Enable Bootstrap floating label style.
Additional CSS classes for the inline label wrapper.
Additional CSS classes for the inline input wrapper.
Enable JavaScript-based error display for client-side validation.
Specify a custom framework theme. Defaults to the configured framework.
Examples
Basic Number Input
With Min and Max Values
With Step Increment
Required Field
With Model Binding
With Default Value
With Placeholder
Floating Label
Inline Layout
Without Label
Decimal Numbers
Percentage Input
With Help Text
Product Order Form
Value Resolution
The component resolves the input value in the following order:- Old input (from validation errors)
- Model value (if model is provided)
- Default value (if specified)
- Empty string
HTML5 Number Validation
The number input type provides built-in browser validation:- Only accepts numeric input
- Supports
min,max, andstepattributes for validation - Provides increment/decrement controls
- Shows browser-specific validation messages
- Works with HTML5 form validation API
Common Attributes
min- Minimum allowed valuemax- Maximum allowed valuestep- Increment step (use0.01for decimals,1for integers)
Validation Error Display
When validation fails, the input automatically:- Adds the
is-invalidBootstrap class - Displays error messages below the input (if
showErrorsistrue) - Preserves user input through Laravel’s old input
Implementation Details
The Number component:- Extends the base Input component with type set to
number - Supports all standard HTML input attributes via attribute merging
- Leverages browser’s native number validation and controls
- Integrates with Laravel’s validation error bag
- Works seamlessly with Laravel’s old input helper
/src/Views/Components/Number.php:12