Anchor Design System

Quantity3.0

The AnchorQuantity component is a web component that displays a number input with incrementer and decrementer buttons.

Installation

npm i @tryg/vue-ui-library

Usage

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-quantity value="0" min="0" max="10"></anchor-quantity>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorQuantity } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-quantity value="0" min="0" max="10"></anchor-quantity>
</template>

Disabled

Vue component
<template>
  <anchor-quantity name="quantity-field" disabled>Write a number</anchor-quantity>
</template>

Props

The AnchorQuantity component accepts the following properties:

  • value: The value of the quantity input.
  • min: The minimum value that the quantity input can have.
  • max: The maximum value that the quantity input can have.
  • disabled: A boolean that determines whether the quantity input is disabled.

In this example, the value property is set to 0, the min property is set to 0, and the max property is set to 10. This displays a quantity input with a value of 0 and incrementer and decrementer buttons that allow the user to increase or decrease the value.

Accessibility

  • Built on a native <input type="number"> element, providing standard keyboard navigation and form control behavior.
  • The increment and decrement buttons carry accessible labels, allowing screen reader users to identify their purpose.
  • Supports aria-valuemin and aria-valuemax attributes mapped from the min and max props to communicate the valid range.
  • The label prop provides an accessible label for the input field.
  • Screen readers announce the current value, minimum, maximum, and step size when the input receives focus.

API

anchor-radio

Properties

PropertyAttributeDescriptionTypeDefault
ariaActivedescendantaria-activedescendantaria-activedescendant attribute for the input fieldstring''
ariaDescribedByaria-described-byaria-describedby attribute for the input fieldstring''
ariaLivearia-livearia-live attribute for the input fieldstringundefined
disableddisabledDisable the input fieldbooleanfalse
errorerrorShow an error state on input fieldbooleanfalse
errorTexterror-textShow an error messagestringundefined
helpTexthelp-textShow a help textstringundefined
inputIdinput-idThe id of the input fieldstring`anchor-quantity-${generateGuid()}`
labellabelShow a label above the input fieldstringundefined
maxmaxThe maximum value of the input fieldnumberundefined
minminThe minimum value of the input fieldnumberundefined
readonlyreadonlySet the field to be read onlybooleanfalse
requiredrequiredMark the field as requiredbooleanfalse
stepstepThe step value of the input fieldnumber1
validityMissingValueTextvalidity-missing-value-textText to be displayed if when value is missing an native form validation is usedstringundefined
valuevalueThe value in the input field. Use this to set a valuenumber0

Events

EventDescriptionType
blureventEvent emitted when the user blurs the input fieldCustomEvent<any>
cleareventEvent emitted when the user clears the input fieldCustomEvent<any>
focuseventEvent emitted when the user is focusing the input fieldCustomEvent<any>
inputChangeEvent emitted when the input is changed. Only triggers when focus leaves the inputCustomEvent<EventDetail>
inputeventEvent emitted when the user is inputting something into the input fieldCustomEvent<EventDetail>

CSS Custom Properties

NameDescription
--quantity-input-max-widthSets the max width of the input field
--quantity-input-widthSets the width of the input field

Dependencies

Depends on

Graph

graph TD;
  anchor-quantity --> anchor-label
  anchor-quantity --> anchor-icon
  anchor-quantity --> anchor-icon-button
  anchor-quantity --> anchor-input
  anchor-input --> anchor-form-field
  anchor-input --> anchor-icon
  anchor-input --> anchor-tooltip
  anchor-form-field --> anchor-icon
  style anchor-quantity fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page