Anchor Design System
Form

Quantity3.0

The anchor-quantity component is a web component that displays a number input with incrementer and decrementer buttons.

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-quantity';
  defineCustomElement();
</script>
<anchor-quantity value="0" min="0" max="10"></anchor-quantity>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<anchor-quantity value="0" min="0" max="10"></anchor-quantity>

Disabled

Webcomponent
<anchor-quantity name="quantity-field" disabled>Write a number</anchor-quantity>

Props

The anchor-quantity 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.

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


Built with StencilJS

On this page