Vueuse math skilld

From skilld-dev/vue-ecosystem-skills · View interactive version

Vueuse math skilld is an AI agent skill from the GitHub repository skilld-dev/vue-ecosystem-skills. Math composables for Vue 3 from @vueuse/math. Use when writing or debugging code that imports "@vueuse/math", or when clamping, projecting, rounding, averaging, summing, or combining reactive numbers in Vue.

How to use this skill

Skill file

@vueuse/math 15.0.0

Reactive math for Vue 3. Every composable resolves inputs with toValue inside a computed, so arguments accept plain numbers, refs, or getters (MaybeRefOrGetter<number>), and the result is a ComputedRef<number> that tracks every input (dist/index.js:70-71). The one exception: useClamp with a mutable ref returns a writable computed (dist/index.d.ts:83).

Environment

Exports

From dist/index.d.ts:167:

Signatures, behavior notes, and per-function examples: references/api.md. Version-specific changes: references/migrations.md.

Common tasks

Writable clamped state; pass a mutable ref so assignments are clamped automatically:

import { useClamp } from '@vueuse/math'

const level = ref(0)
const clamped = useClamp(level, 0, 10)
clamped.value = 15 // clamped.value and level.value are 10

Read-only clamp; pass a getter or readonly ref (dist/index.js:113):

const ratio = useClamp(() => raw.value / total.value, 0, 1)

Aggregate fixed refs with rest arguments instead of building an array (dist/index.d.ts:154-155):

const total = useSum(refA, refB, refC)
const peak = useMax(refA, refB, refC)

Map a value between domains, for sliders, charts, or progress UIs:

const progress = useProjection(scrollY, [0, pageHeight], [0, 100])

Reuse one projection across components; domains may be reactive:

const toPercent = createProjection(domain, [0, 100])
const a = toPercent(inputA)

Round to decimal places and keep a number, not the string toFixed returns:

const price = usePrecision(ref(3.1415), 2) // 3.14
const up = usePrecision(ref(3.1415), 2, { math: 'ceil' }) // 3.15

Combine boolean flags reactively, then feed side effects to whenever from @vueuse/core:

import { whenever } from '@vueuse/core'
import { logicAnd } from '@vueuse/math'

whenever(logicAnd(ready, hasData), run)

Rules and pitfalls

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.