Skip to main content
Vuetify0 is now in beta!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createNumeric

Pure numeric math for bounded values with step snapping, range clamping, and floating-point precision correction.

Usage

ts
import { createNumeric } from '@vuetify/v0'

const numeric = createNumeric({ min: 0, max: 100, step: 5 })

numeric.snap(47)        // 45
numeric.snap(48)        // 50
numeric.up(50)          // 55
numeric.down(50)        // 45
numeric.floor()         // 0
numeric.ceil()          // 100
numeric.fromValue(50)   // 50 (percentage)
numeric.fromPercent(33) // 30 (snapped value)
numeric.canUp(100)      // false
numeric.canDown(0)      // false

Architecture

Diagram

Use controls to zoom and pan. Click outside or press Escape to close.

Reactivity

createNumeric is a pure function factory — it returns plain functions, not reactive refs. This makes it composable with any reactive system.

MethodReturnsDescription
snap(value)numberRound to nearest step, clamp to [min, max]
up(value, multiplier?)numberIncrement by step × multiplier
down(value, multiplier?)numberDecrement by step × multiplier
floor()numberReturn min value
ceil()numberReturn max value
fromValue(value)numberConvert value to 0–100 percentage
fromPercent(percent)numberConvert percentage to snapped value
canUp(value)booleanWhether increment is possible
canDown(value)booleanWhether decrement is possible

Examples

Bounded Stepper

Increment/decrement buttons with canUp/canDown guards and a percentage display, showing how createNumeric handles boundary enforcement and value-to-percent conversion.

50
50% of range

API Reference

The following API details are for the createNumeric composable.
Was this page helpful?

Ctrl+/