Overview
The quantity selector component is a Vue component that lets users choose a numeric quantity using a decrease button, a number input, and an increase button. It clamps values to a configurable range and emits both an immediate value update and a debounced change event, making it well suited to cart-style interactions that trigger API calls.
Basic usage
Importing the component
To use the quantity selector component, import it along with its styles:
import { DsQuantitySelector } from "@coloplast/design-system";
import "@coloplast/design-system/dist/components/quantity-selector/ds-quantity-selector.css";
Example usage
The component works with v-model. The accessible labels for the input and the two buttons are required:
<template>
<DsQuantitySelector
v-model="quantity"
aria-label-input="Quantity"
aria-label-decrease-quantity="Decrease quantity"
aria-label-increase-quantity="Increase quantity"
:min="1"
:max="99"
@change="updateBasket"
/>
</template>
<script setup>
import { ref } from "vue";
import { DsQuantitySelector } from "@coloplast/design-system";
const quantity = ref(1);
const updateBasket = (value) => {
// debounced - a good place to call an API
};
</script>
The update:modelValue event (used by v-model) fires immediately, while the change event is debounced (debounce-duration, default 200ms) so you can safely trigger network requests from it. Values are coerced to whole numbers and clamped between min and max; the buttons step by step and disable automatically at the bounds.
Component playground and props
Explore and test the props via the ‘Controls’ tab in the interactive Storybook example: