Numeric Field
BsNumericField is a component that let users enter numeric text into an UI.
Overview
BsNumericField component mimics the HTML5 <input type="number">
behaviour. This means that you can add attributes like required
, readonly
, or disabled
and it will react to them to give the best experience. You can also use v-model
directive to create two-way data bindings on the model-value
property.
Additionally, you can use keyboard UP/DOWN arrow to increment or decrement the value.
IMPORTANT
Do not use the model-value
property when using v-model
.
Style Variants
You can style <bs-numeric-field>
to your own preference or use a style variant based on Google Material Design 2 or Material Design 3 specifications.
Default
You can style <bs-numeric-field>
that follows Google Material Design 2 specifications by using floating-label
property explicitly.
Filled
Use filled
property explicitly to enable <bs-numeric-field>
with solid fill style. And when combined with floating-label
property, <bs-numeric-field>
will have a style that follows the Google Material Design 3 specifications.
Outlined
Use outlined
property explicitly to enable <bs-numeric-field>
with outline style. And when combined with floating-label
property, <bs-numeric-field>
will have a style that follows the Google Material Design 3 specifications.
Rounded Filled
Combine filled
property and rounded
property explicitly to enable <bs-numeric-field>
with rounded pill solid style.
Rounded Outlined
Combine outlined
property and rounded
property explicitly to enable <bs-numeric-field>
with rounded pill outline style.
Action Buttons
The BsNumericField has two variants of action buttons to increment/decrement the numeric value.
Spin Buttons
The Spin action buttons is the default action buttons. They can be placed on the left or right side (default).
Plus-Minus Buttons
The Plus-Minus action buttons can be enabled by defining the action-button
property explicitly and sets the spin-button
property to false
. They can be placed on the left, right (default) or both side.
Clearable
Define the clear-button
property explicitly, so that the field value can be cleared easily.
Help Text
The help-text
property on <bs-numeric-field>
adds an help text beneath the numeric field. And sets the persistent-help-text
property to false
will make the help text visible only when the numeric field is focused.
Icons
The properties prepend-icon
, prepend-icon-outer
, append-icon
and append-icon-outer
provides the ability to add icon to <bs-numeric-field>
.
Use any valid android icon name from Google Material Symbols with or without a suffix. Valid suffixes are: _outlined
, _rounded
, _sharp
, _filled
, _outlined_filled
, _rounded_filled
, and _sharp_filled
. Suffix _filled
and _outlined_filled
will display the same icon style variant.
INFO
Since Vue MDBootstrap v2.1.0, Google Material Icons are replaced with Google Material Symbols.
Prefixes and Suffixes
The prefix and suffix properties allows you to prepend and append inline non-modifiable text before or after the input field.
Added since v2.0.10Usage Example
The following is an example that demonstrate more advanced use of the <bs-numeric-field>
with form validation.
CSS Variables
Updated on v2.0.10--md-field-active-border-color: rgb(var(--md-field-active-indicator));
--md-field-active-border-width: 2px;
--md-field-color-bg: currentColor;
--md-field-border-color: currentColor;
--md-field-border-width: 1px;
--md-field-control-height: 3.5rem;
--md-field-floating-label-color: var(--md-field-label-color);
--md-field-label-color: currentColor;
--md-field-padding-start: 1rem;
--md-field-padding-end: 1rem;
--md-field-padding-top: 1.625rem;
--md-field-padding-bottom: 0.375rem;
--md-field-inline-text-font-weight: 500;
// global css variables
--md-field-primary-indicator-rgb: 98, 0, 238;
--md-field-primary-indicator: rgb(var(--md-field-primary-indicator-rgb));
--md-field-accent-indicator-rgb: 185,156,225;
--md-field-accent-indicator: rgb(var(--md-field-accent-indicator-rgb));
--md-field-active-indicator: var(--md-field-primary-indicator-rgb);
API Reference
TValidator
The validator configuration option has properties as described below:
Property | Type | Description |
---|---|---|
validators | Record<String ,Boolean> | External validator plugin validation result. |
messages | Record<String ,String> | Validation message for each validation types. |
hasError | Boolean | An indicator that tells the field value pass the validation or not. |
dirty | Boolean | Value comes from validator plugin that indicate the field is dirty or not. |
All properties are mandatory.
NOTE
Vue MDBootstrap does not include form validation by default, we leave that up to the 3rd party form validation plugin. As of now, Vuelidate has been fully tested with our component library.