Skip to main content
Vuetify0 is now in alpha!
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

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

API Reference

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

Ctrl+/