--- title: "Quantity" slug: quantity category: component type: documentation version: 20.0.0 tokens: 904 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-quantity--documentation.txt --- # Quantity _**Quantity** is a component used to enter and modify a numeric value in a responsive and easy way_ ## Overview Form Guidelines] } figmaLink="https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=49-9160" githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/quantity" name="Quantity"> The **Quantity** component provides a user-friendly interface for selecting or entering numerical values. It includes an **Input** field combined with increment and decrement **Buttons** to adjust the value easily. | | | |---|---| | Name | undefined | | Also known as | Numeric, Number input, Amount | ## Usage **Quantity** is used to quickly adjust with a few clicks a numeric value within defined parameters. Limits can be set as minimum or maximum value. In that case, the numeric value cannot exceed the defined boundaries. ### Dos & Don'ts **Do** - Use the Quantity component for small, incremental adjustments where users are likely to increase or decrease values with just a few clicks - Always allow users to manually input a number directly into the field, not just through the increment/decrement buttons - Set appropriate min/max limits to prevent invalid or unintended values - Provide contextual labels or grouping when needed to clarify what the quantity refers to **Don't** - Don't use the Quantity component for large numeric changes that would require excessive clicking. Prefer a freeform numeric input or slider in those cases - Don't use the component outside of quantitative contexts: it should only be used to adjust measurable numeric values (e.g., quantity, amount) ### Best Practices in Context 1. **Quantity** 2. **Decrement button** 3. **Input field** 4. **Increment button** ## Placement **Quantity** can be used to let users easily change an amount of items, for example, or similar situations. It should be used with numeric **Input** that are in a fairly narrow range. ## Behavior **Quantity** numeric field can be edited directly by the user. The user can also decrease or increase the value by clicking on the **Buttons**. In case that limits have been set to minimum and maximum value, corresponding control will be disabled when this value has been reached. Each item of the **Quantity** component can be focused; the whole component can be disabled at once. ## Navigation ### Focus Management When the **Quantity** component is focused, focus is automatically set to the input if not disabled. If the **Input** field is read-only, it can still receive focus but cannot be edited. ### General Keyboard Shortcuts Pressing `Tab` moves focus forward the input field. Pressing `Shift` + `Tab` moves focus backward through the interactive elements. Pressing `Arrow Up` when focused in the Input field increases the value. Pressing `Arrow Down` when focused in the Input field decreases the value. ## Accessibility This component complies with the [Spinbutton WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) ### Always provide an explicit label Every **Quantity** must have a clear and explicit label to ensure that users (especially screen reader users) understand its purpose, using either **FormField** or a native label tag. ```tsx Number of CPUs: ``` Screen readers will announce the label and the quantity field.