Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useCssVar.md
1---2category: Browser3---45# useCssVar67Manipulate CSS variables89## Usage1011```ts12import { useCssVar } from '@vueuse/core'13import { useTemplateRef } from 'vue'1415const el = useTemplateRef('el')16const color1 = useCssVar('--color', el)1718const elv = useTemplateRef('elv')19const key = ref('--color')20const colorVal = useCssVar(key, elv)2122const someEl = useTemplateRef('someEl')23const color2 = useCssVar('--color', someEl, { initialValue: '#eee' })24```2526## Type Declarations2728```ts29export interface UseCssVarOptions extends ConfigurableWindow {30initialValue?: string31/**32* Use MutationObserver to monitor variable changes33* @default false34*/35observe?: boolean36}37/**38* Manipulate CSS variables.39*40* @see https://vueuse.org/useCssVar41* @param prop42* @param target43* @param options44*/45export declare function useCssVar(46prop: MaybeRefOrGetter<string | null | undefined>,47target?: MaybeElementRef,48options?: UseCssVarOptions,49): ShallowRef<string | undefined, string | undefined>50```51