Skip to content
On this page

useClamp

Category
Last Changed
7 days ago

Reactively clamp a value between two other values.

Demo

min: max: value:0

Usage

import { useClamp } from '@vueuse/core'

const min = ref(0)
const max = ref(10)
const value = useClamp(0, min, max)
import { useClamp } from '@vueuse/core'

const min = ref(0)
const max = ref(10)
const value = useClamp(0, min, max)

Type Declarations

/**
 * 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: MaybeRef<number>,
  max: MaybeRef<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: MaybeRef<number>,
  max: MaybeRef<number>
): Ref<number>

Source

SourceDemoDocs

Contributors

Jelf
Anthony Fu

Changelog

v7.1.0 on 11/24/2021
e6659 - feat: new function (#953)
useClamp has loaded