useClamp
Reactively clamp a value between two other values.
Demo
min: max: value:0
Usage
ts
import { useClamp } from '@vueuse/math'
const min = ref(0)
const max = ref(10)
const value = useClamp(0, min, max)
import { useClamp } from '@vueuse/math'
const min = ref(0)
const max = ref(10)
const value = useClamp(0, min, max)
Type Declarations
typescript
/**
* Reactively clamp a value between two other values.
*
* @see https://vueuse.org/useClamp
* @param value number
* @param min
* @param max
*/
export declare function useClamp(
value: MaybeRef<number>,
min: MaybeComputedRef<number>,
max: MaybeComputedRef<number>
): Ref<number>
/**
* Reactively clamp a value between two other values.
*
* @see https://vueuse.org/useClamp
* @param value number
* @param min
* @param max
*/
export declare function useClamp(
value: MaybeRef<number>,
min: MaybeComputedRef<number>,
max: MaybeComputedRef<number>
): Ref<number>
Source
Contributors
Anthony Fu