Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Accessibility
Vuetify
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

useBreakpoints

The useBreakpoints composable provides comprehensive responsive design capabilities through reactive viewport dimension detection. It automatically tracks window size changes and provides boolean flags for current breakpoint ranges, enabling mobile-first and responsive layouts.


Intermediate97.2% coverageMar 12, 2026

Installation

Install the Breakpoints plugin in your app’s entry point:

main.ts
import { createApp } from 'vue'
import { createBreakpointsPlugin } from '@vuetify/v0'
import App from './App.vue'

const app = createApp(App)

app.use(
  createBreakpointsPlugin({
    mobileBreakpoint: 'sm',
    breakpoints: {
      xs: 0,
      sm: 680,
      md: 1024,
      lg: 1280,
      xl: 1920,
      xxl: 2560,
    },
  })
)

app.mount('#app')

Usage

Once the plugin is installed, use the useBreakpoints composable in any component. Destructure the properties you need for automatic ref unwrapping in templates:

vue
<script setup lang="ts">
  import { useBreakpoints } from '@vuetify/v0'

  const { isMobile, mdAndUp, name, width, height } = useBreakpoints()

  if (isMobile.value) {
    console.log('Mobile detected')
  }
</script>

<template>
  <div>
    <!-- Destructured refs auto-unwrap in templates -->
    <nav v-if="mdAndUp">
      <!-- Desktop navigation -->
    </nav>
    <nav v-else>
      <!-- Mobile navigation -->
    </nav>

    <p v-if="isMobile">Mobile layout active</p>
    <p>Current breakpoint: {{ name }}</p>
    <p>Viewport: {{ width }} x {{ height }}</p>
  </div>
</template>
Tip

When using the composable without destructuring, access .value in templates: v-if="breakpoints.isMobile.value". Destructuring to top-level variables enables Vue’s automatic ref unwrapping.

Architecture

useBreakpoints uses the plugin pattern with viewport observation:

Breakpoints Plugin

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

Breakpoints Plugin

Reactivity

All breakpoint properties are Readonly<ShallowRef> and automatically update when the viewport size changes. Use .value in script; destructure for template auto-unwrapping.

PropertyTypeNotes
nameShallowRef<BreakpointName>Current breakpoint name
widthShallowRef<number>Viewport width in pixels
heightShallowRef<number>Viewport height in pixels
isMobileShallowRef<boolean>Below mobile breakpoint threshold
xs / sm / md / lg / xl / xxlShallowRef<boolean>Exact breakpoint matches
smAndUp / mdAndUp / etc.ShallowRef<boolean>At or above breakpoint
smAndDown / mdAndDown / etc.ShallowRef<boolean>At or below breakpoint
breakpointsRecord<string, number>Static config object (not reactive)
ssrbooleantrue when running server-side with SSR options

SSR Support

By default, useBreakpoints returns xs / width 0 on the server. Pass ssr options to render at a known viewport size:

main.ts
app.use(
  createBreakpointsPlugin({
    ssr: {
      clientWidth: 1280,
      clientHeight: 800,
    },
  })
)

On the server, all breakpoint flags are computed from the SSR dimensions — so v-if="mdAndUp" renders correctly in SSR output. On hydration, real window.innerWidth / innerHeight replace the SSR values.

Tip

In Nuxt, read the viewport from a cookie or user-agent hint so the SSR dimensions match the actual device. See the Nuxt integration guide for a cookie-based example.

API Reference

The following API details are for the useBreakpoints composable.

Functions

createBreakpoints

(_options?: BreakpointsOptions) => E

Creates a new breakpoints instance.

createBreakpointsContext

<_E>(_options?: BreakpointsContextOptions | undefined) => ContextTrinity<_E>

createBreakpointsPlugin

(_options?: BreakpointsContextOptions | undefined) => Plugin

useBreakpoints

<_E>(namespace?: string) => _E

Options

namespace

string | undefined

mobileBreakpoint

number | BreakpointName | undefined

breakpoints

Partial<Record<BreakpointName, number>> | undefined

ssr

{ clientWidth: number; clientHeight?: number; } | undefined

Properties

breakpoints

Readonly<Record<BreakpointName, number>>

name

Readonly<ShallowRef<BreakpointName>>

width

Readonly<ShallowRef<number>>

height

Readonly<ShallowRef<number>>

isMobile

Readonly<ShallowRef<boolean>>

xs

Readonly<ShallowRef<boolean>>

sm

Readonly<ShallowRef<boolean>>

md

Readonly<ShallowRef<boolean>>

lg

Readonly<ShallowRef<boolean>>

xl

Readonly<ShallowRef<boolean>>

xxl

Readonly<ShallowRef<boolean>>

smAndUp

Readonly<ShallowRef<boolean>>

mdAndUp

Readonly<ShallowRef<boolean>>

lgAndUp

Readonly<ShallowRef<boolean>>

xlAndUp

Readonly<ShallowRef<boolean>>

xxlAndUp

Readonly<ShallowRef<boolean>>

smAndDown

Readonly<ShallowRef<boolean>>

mdAndDown

Readonly<ShallowRef<boolean>>

lgAndDown

Readonly<ShallowRef<boolean>>

xlAndDown

Readonly<ShallowRef<boolean>>

xxlAndDown

Readonly<ShallowRef<boolean>>

ssr

boolean

Methods

update

() => void
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/