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.

Default
Stateful
Manual-input
Open in GitHub

Style
#

There are tree styles for component: default (solid), outline, bordered.

Open in GitHub

Buttons
#

By default, va-counter uses internal icons. The component with prop buttons will use external buttons.

Open in GitHub

Width
#

You can set the width of the entire component with width, as well as the indentation of external buttons with margins.

Open in GitHub

Buttons style
#

You can select different button styles using properties flat (by default flat = true), rounded (by default rounded = false) and margins.

Open in GitHub

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.

Open in GitHub

State
#

Component can be disabled or readonly.

Open in GitHub

Max, min, step
#

You can define min, max and step values.

-100 to 100 with step=10
manual input
Open in GitHub

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.

10 copies
Open in GitHub

API
#

Props #

NameDescriptionTypesDefault
aria-decrease-label

The aria-label of decrease button

String

"$t:decreaseCounter"

aria-increase-label

The aria-label of increase button

String

"$t:increaseCounter"

aria-label

The aria-label of content of counter

String

"$t:counterValue"

bordered

Applies component underscore styling

Boolean

-

buttons

Enables display of the component with external buttons

Boolean

false

color

Sets component color

String

"primary"

decrease-icon

Sets a decrease icon

String

"remove"

disabled

Disable the component

Boolean

false

flat

Applies flat styling of outside buttons

Boolean

true

increase-icon

Sets an increase icon

String

"add"

label

Sets component label

String

""

long-press-delay

The number of milliseconds after which another event will be sent when you are long pressing the button

Number

500

manual-input

Allows user to manually input value

Boolean

false

margins

Sets the margin of the outside buttons

String | Number

"4px"

max

The maximum value to accept for this input

Number

-

messages

Displays a list of hint messages (or message if using a string)

Array | String

[]

min

The minimum value to accept for this input

Number

-

model-value

The value of the v-model bindings.

String | Number

0

outline

Applies component outline styling

Boolean

-

preset

Named preset combination of component props.

String

-

readonly

Puts component in readonly state

Boolean

false

rounded

Adds rounded corners to outside buttons

Boolean

false

stateful

Add possibility to work with component without setting v-model.

Boolean

false

step

Step of changing input field values

Number

1

text-color

Text color (theme string or HEX string).

String

-

width

Sets a component width

String | Number

"160px"

Events #

NameDescription

blur

On blur.

change

The change input event is fired when input is submitted (when manual-input prop enabled)

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 v-model

Slots #

NameDescription

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 #

NameDefault Value
--va-counter-button-inner-padding 6px
--va-counter-button-outer-padding 8px