useCssVar
Manipulate CSS variables
Demo
Usage
js
import { useCssVar } from '@vueuse/core'
const el = ref(null)
const color = useCssVar('--color', el)
const elv = ref(null)
const key = ref('--color')
const colorVal = useCssVar(key, elv)
const someEl = ref(null)
const color = useCssVar('--color', someEl, { initialValue: '#eee' })
import { useCssVar } from '@vueuse/core'
const el = ref(null)
const color = useCssVar('--color', el)
const elv = ref(null)
const key = ref('--color')
const colorVal = useCssVar(key, elv)
const someEl = ref(null)
const color = useCssVar('--color', someEl, { initialValue: '#eee' })
Type Declarations
typescript
export interface UseCssVarOptions extends ConfigurableWindow {
initialValue?: string
}
/**
* Manipulate CSS variables.
*
* @see https://vueuse.org/useCssVar
* @param prop
* @param target
* @param initialValue
* @param options
*/
export declare function useCssVar(
prop: MaybeComputedRef<string>,
target?: MaybeElementRef,
{ window, initialValue }?: UseCssVarOptions
): Ref<string>
export interface UseCssVarOptions extends ConfigurableWindow {
initialValue?: string
}
/**
* Manipulate CSS variables.
*
* @see https://vueuse.org/useCssVar
* @param prop
* @param target
* @param initialValue
* @param options
*/
export declare function useCssVar(
prop: MaybeComputedRef<string>,
target?: MaybeElementRef,
{ window, initialValue }?: UseCssVarOptions
): Ref<string>
Source
Contributors
Anthony Fu
Antério Vieira
木荣
JD Solanki
btea
Alex Kozack