Constants
SSR-safe boolean constants for environment detection. All evaluate at module load time and are tree-shakeable.
import { IN_BROWSER, SUPPORTS_TOUCH } from '@vuetify/v0/constants'IN_BROWSER
true when running in a browser context. Use this instead of raw typeof window !== 'undefined' checks.
import { IN_BROWSER } from '@vuetify/v0/constants'
if (IN_BROWSER) {
// Safe to access window, document, localStorage, etc.
window.addEventListener('resize', onResize)
}SUPPORTS_TOUCH
true when the device supports touch input. Checks for ontouchstart on window or navigator.maxTouchPoints > 0.
import { SUPPORTS_TOUCH } from '@vuetify/v0/constants'
if (SUPPORTS_TOUCH) {
// Bind touch-specific handlers
}SUPPORTS_MATCH_MEDIA
true when window.matchMedia is available. Required by useMediaQuery and useBreakpoints.
import { SUPPORTS_MATCH_MEDIA } from '@vuetify/v0/constants'
if (SUPPORTS_MATCH_MEDIA) {
const mq = window.matchMedia('(prefers-color-scheme: dark)')
}SUPPORTS_OBSERVER
true when ResizeObserver is available. Required by useResizeObserver.
import { SUPPORTS_OBSERVER } from '@vuetify/v0/constants'
if (SUPPORTS_OBSERVER) {
const observer = new ResizeObserver(onResize)
}SUPPORTS_INTERSECTION_OBSERVER
true when IntersectionObserver is available. Required by useIntersectionObserver.
import { SUPPORTS_INTERSECTION_OBSERVER } from '@vuetify/v0/constants'
if (SUPPORTS_INTERSECTION_OBSERVER) {
const observer = new IntersectionObserver(onIntersect)
}SUPPORTS_MUTATION_OBSERVER
true when MutationObserver is available. Required by useMutationObserver.
import { SUPPORTS_MUTATION_OBSERVER } from '@vuetify/v0/constants'
if (SUPPORTS_MUTATION_OBSERVER) {
const observer = new MutationObserver(onMutate)
}version
The current package version string. Resolves to the build-time version in production, or '0.0.0' in development:
import { version } from '@vuetify/v0/constants'
console.log(version) // e.g. '0.4.2'HTML Elements
SELF_CLOSING_TAGS is exported for component and renderer authoring.
SELF_CLOSING_TAGS
A Set<string> of all HTML void elements that cannot have children:
import { SELF_CLOSING_TAGS, isSelfClosingTag } from '@vuetify/v0/constants'
SELF_CLOSING_TAGS.has('input') // true
SELF_CLOSING_TAGS.has('div') // false
isSelfClosingTag('br') // true
isSelfClosingTag('span') // falseReference
| Constant | Checks |
|---|---|
IN_BROWSER | typeof window !== 'undefined' |
SUPPORTS_TOUCH | ontouchstart or maxTouchPoints > 0 |
SUPPORTS_MATCH_MEDIA | window.matchMedia exists and is a function |
SUPPORTS_OBSERVER | window.ResizeObserver exists |
SUPPORTS_INTERSECTION_OBSERVER | window.IntersectionObserver exists |
SUPPORTS_MUTATION_OBSERVER | window.MutationObserver exists |
All SUPPORTS_* constants depend on IN_BROWSER—they are always false during SSR. You don’t need to check IN_BROWSER separately when using them.