--- import DefaultLayout from '@shared/layouts/DefaultLayout.astro' import Card from '@ui/Card.astro' import CardBody from '@ui/CardBody.astro' import CardTitle from '@ui/CardTitle.astro' import CardSubtitle from '@ui/CardSubtitle.astro' import DocsLink from '@ui/DocsLink.astro' import FormGroup from '@ui/FormGroup.astro' import Stepper from '@ui/Stepper.astro' import Icon from '@ui/Icon.astro' const cart = [ { name: 'Hex nut M8 DIN 934, zinc plated', code: '8-934-8-ZN', price: '12.40', quantity: 2, max: 50 }, { name: 'Lock nut M8 DIN 985, stainless A2', code: '8-985-A2', price: '28.90', quantity: 1, max: 20 }, { name: 'Cap nut M8 DIN 1587, brass', code: '8-1587-MS', price: '41.00', quantity: 3, max: 3 }, ] ---
Basic Add data-bs-toggle="stepper" to the input; the plugin renders the box and the buttons, min and max set the bounds.
At a bound The button at min or max goes disabled, so the user sees the value cannot go further.
Step and precision A fractional step sets how many decimals the value keeps.
Sizes Add .form-control-sm or .form-control-lg to the input; the box gets .stepper-sm or -lg.
Without bounds Without min and max the value goes both ways, so a minus sign can be typed too.
Native number input Use type="number" to keep the browser's own validation; the stepper only hides its spin buttons.
No repeat Add data-bs-repeat="false" to step once per click instead of repeating while the button is held.
Wider input Set --tblr-stepper-input-width on the input for longer values.
Disabled and readonly Add disabled or readonly to the input; both buttons follow.
Validation Add .is-valid or .is-invalid to the input, like on any .form-control; the feedback text after it still shows.
In stock, ships today.
Only 5 pieces left.
Custom buttons Write the .stepper markup yourself to change the icons or labels; data-bs-stepper-action marks the buttons.
With a label and hint A stepper sits in a FormGroup like any other control.
In a cart The usual place for a stepper: a quantity per line, with max set to the stock.
{ cart.map((item) => ( )) }
Product Price Quantity
{item.name}
{item.code}
${item.price}