Skip to content
On this page

useCssVar

Category
Last Changed
20 days ago

Manipulate CSS variables

Demo

Sample text,
Sample text, --color:

Usage

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)
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)

Type Declarations

/**
 * Manipulate CSS variables.
 *
 * @see https://vueuse.org/useCssVar
 * @param prop
 * @param el
 * @param options
 */
export declare function useCssVar(
  prop: MaybeRef<string>,
  target?: MaybeElementRef,
  { window }?: ConfigurableWindow
): Ref<string>
/**
 * Manipulate CSS variables.
 *
 * @see https://vueuse.org/useCssVar
 * @param prop
 * @param el
 * @param options
 */
export declare function useCssVar(
  prop: MaybeRef<string>,
  target?: MaybeElementRef,
  { window }?: ConfigurableWindow
): Ref<string>

Source

SourceDemoDocs

Contributors

Anthony Fu
Antério Vieira
btea
Alex Kozack

Changelog

v7.6.2 on 2/13/2022
f99ea - feat: support prop be ref (#1236)
useCssVar has loaded