Counter #
The va-counter
component is intended to be used as a simple counter.
Examples #
Basic usage #
By default, va-counter
has v-model
prop, and may also include stateful
state. With manual-input
the user can manually enter a value.
Style #
There are tree styles for component: default (solid), outline, bordered.
Buttons #
By default, va-counter
uses internal icons. The component with prop buttons
will use external buttons.
Width #
You can set the width of the entire component with width
, as well as the indentation of external buttons with margins
.
Buttons style #
You can select different button styles using properties flat
(by default flat = true
), rounded
(by default rounded = false
) and margins
.
Custom icons and colors #
You can select different icons using the increaseIcon
and decreaseIcon
properties, and you can also select colors using color
and text-color
.
State #
Component can be disabled
or readonly
.
Max, min, step #
You can define min
, max
and step
values.
Slots #
You can use slots for pass custom elements: content
(you can access to value) instead of input element, decreaseAction
(you can access to decrease function) instead of decrease icon or button and increaseAction
(you can access to increase function) instead of increase icon or button.
API #
Props #
Name | Description | Types | Default |
---|---|---|---|
aria-decrease-label | The aria-label of decrease button |
|
|
aria-increase-label | The aria-label of increase button |
|
|
aria-label | The aria-label of content of counter |
|
|
bordered | Applies component |
| - |
buttons | Enables display of the component with external buttons |
|
|
color | Sets component color |
|
|
decrease-icon | Sets a decrease icon |
|
|
disabled | Disable the component |
|
|
flat | Applies |
|
|
increase-icon | Sets an increase icon |
|
|
label | Sets component label |
|
|
long-press-delay | The number of milliseconds after which another event will be sent when you are long pressing the button |
|
|
manual-input | Allows user to manually input value |
|
|
margins | Sets the margin of the outside buttons |
|
|
max | The maximum value to accept for this input |
| - |
messages | Displays a list of hint messages (or message if using a string) |
|
|
min | The minimum value to accept for this input |
| - |
model-value | The value of the |
|
|
outline | Applies component |
| - |
preset | Named preset combination of component props. |
| - |
readonly | Puts component in readonly state |
|
|
rounded | Adds rounded corners to outside buttons |
|
|
stateful | Add possibility to work with component without setting |
|
|
step | Step of changing input field values |
|
|
text-color | Text color (theme string or HEX string). |
| - |
width | Sets a component width |
|
|
Events #
Name | Description |
---|---|
blur | On blur. |
change | The change input event is fired when input is submitted (when |
click-decrease-button | The event is triggered when clicked decrease outside button |
click-decrease-icon | The event is triggered when clicked decrease inner icon |
click-increase-button | The event is triggered when clicked increase outside button |
click-increase-icon | The event is triggered when clicked increase inner icon |
focus | On focus. |
update-model-value | The event is triggered when the component needs to change the model. Is also used by |
Slots #
Name | Description |
---|---|
content | Adds an item instead the input |
decreaseAction | Adds an item instead of decrease icon or button |
increaseAction | Adds an item instead of increase icon or button |
Css Variables #
Name | Default Value |
---|---|
--va-counter-button-inner-padding | 6px |
--va-counter-button-outer-padding | 8px |