Stepper
The 94×32 pt capsule with − and + halves on iOS 26; AppKit’s 20×26 vertical stepper on macOS 26.
Paired with a value
Copies
1
"use client"
import { useState } from "react"
import { Stepper } from "@applecn/ui/components/stepper"
import { Text } from "@applecn/ui/components/text"
export default function StepperBasic() {
const [copies, setCopies] = useState(1)
return (
<div className="flex items-center justify-between rounded-4xl bg-card px-4 py-2">
<Text>Copies</Text>
<div className="flex items-center gap-4">
<Text color="label-2" className="tabular-nums">
{copies}
</Text>
<Stepper
aria-label="Copies"
value={copies}
min={1}
max={99}
onValueChange={(v) => setCopies(v ?? 1)}
/>
</div>
</div>
)
}Install
From the registry this site publishes, with dependencies resolved by the CLI.
npx shadcn@latest add https://applecn.vercel.app/r/stepper.jsonSource
packages/ui/src/components/stepper.tsx
"use client"
import { NumberField as NumberFieldPrimitive } from "@base-ui/react/number-field"
import {
ArrowDown01Icon,
ArrowUp01Icon,
MinusSignIcon,
PlusSignIcon,
} from "@hugeicons/core-free-icons"
import { cn } from "cn"
import { usePlatform } from "../lib/platform"
import { Icon } from "./icon"
/**
* The stepper (HIG › Steppers). iOS 26: the 94×32 capsule with − and + halves; macOS 26:
* AppKit's 20×26 vertical control with stacked chevrons on the bezel; the web a 64×28 pair.
* It shows no value itself — pair it with a label or text field bound to `onValueChange`. The
* value input stays in the tree for the keyboard and assistive technology, visually hidden.
*/
type StepperProps = NumberFieldPrimitive.Root.Props & {
"aria-label": string
className?: string
}
const segmentClassName =
"flex flex-1 items-center justify-center text-label transition-[background-color] duration-(--duration-press) outline-none hover:bg-fill-4 focus-visible:ring-4 focus-visible:ring-ring/60 focus-visible:ring-inset active:bg-fill-2 disabled:pointer-events-none disabled:opacity-30"
function Stepper({ className, "aria-label": label, ...props }: StepperProps) {
const vertical = usePlatform() === "macos"
const increment = (
<NumberFieldPrimitive.Increment
aria-label="Increment"
data-slot="stepper-increment"
className={segmentClassName}
>
<Icon
icon={vertical ? ArrowUp01Icon : PlusSignIcon}
weight="bold"
scale={vertical ? "small" : "medium"}
/>
</NumberFieldPrimitive.Increment>
)
const decrement = (
<NumberFieldPrimitive.Decrement
aria-label="Decrement"
data-slot="stepper-decrement"
className={segmentClassName}
>
<Icon
icon={vertical ? ArrowDown01Icon : MinusSignIcon}
weight="bold"
scale={vertical ? "small" : "medium"}
/>
</NumberFieldPrimitive.Decrement>
)
const divider = (
<span
data-slot="stepper-divider"
aria-hidden="true"
className={cn(
"bg-separator",
vertical ? "mx-0 h-[0.5px] w-full" : "my-1.5 w-[0.5px]"
)}
/>
)
return (
<NumberFieldPrimitive.Root data-slot="stepper-root" {...props}>
<NumberFieldPrimitive.Group
role="group"
aria-label={label}
data-slot="stepper"
data-orientation={vertical ? "vertical" : "horizontal"}
className={cn(
"inline-flex h-(--stepper-height) w-(--stepper-width) shrink-0 items-stretch overflow-hidden rounded-stepper bg-fill-3",
vertical && "flex-col bg-background-3 shadow-control",
className
)}
>
{vertical ? increment : decrement}
{divider}
<NumberFieldPrimitive.Input
aria-label={label}
data-slot="stepper-input"
className="sr-only"
/>
{vertical ? decrement : increment}
</NumberFieldPrimitive.Group>
</NumberFieldPrimitive.Root>
)
}
export { Stepper }
export type { StepperProps }