Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One

Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

toElement

Resolves various element reference types to a plain DOM Element. Accepts refs, getters, raw DOM elements, or Vue component instances and normalizes them to a single Element | undefined.


Intermediate93.8% coverageMar 23, 2026

Usage

ts
import { toElement } from '@vuetify/v0'
import { useTemplateRef } from 'vue'

const el = useTemplateRef<HTMLDivElement>('target')

const element = toElement(el) // HTMLDivElement | undefined

Architecture

toElement resolves multiple input shapes to a DOM element:

Element Resolution

Use controls to zoom and pan. Click outside or press Escape to close.

Element Resolution

Reactivity

toElement is a pure transformer function. It does not track reactivity or return reactive values.

Tip

Use inside computed for reactivity Wrap in computed() if you need reactive element resolution:

ts
const resolved = computed(() => toElement(targetRef))

Supported Input Types

InputResult
Ref<HTMLElement>Unwrapped element
ShallowRef<Element>Unwrapped element
() => HTMLElementCalled, returns element
HTMLElement / SVGElementPass-through
ComponentPublicInstanceExtracts $el
null / undefinedReturns undefined
Tip

Structural typing Uses { readonly value: T } instead of Vue’s nominal Ref<T> to avoid type mismatches across Vue versions.

API Reference

The following API details are for the toElement composable.

Functions

toElement

(target: MaybeElementRef) => Element | undefined

Resolves a {@link MaybeElementRef} to a DOM Element or undefined. Handles: - `Ref<Element>`, `ShallowRef<HTMLElement>`, getter functions - Vue component instances (extracts `$el`) - Raw DOM elements (pass-through) - null/undefined (returns undefined)

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/