UNPKG

@mozaic-ds/vue

Version:

Mozaic-Vue is the Vue.js implementation of ADEO Design system

21 lines (15 loc) 435 B
import { ref, onMounted, onUnmounted } from 'vue'; export function useIsMobile(breakpoint = 780) { const isMobile = ref(false); const update = () => { isMobile.value = window.matchMedia(`(max-width: ${breakpoint}px)`).matches; }; onMounted(() => { update(); window.addEventListener('resize', update); }); onUnmounted(() => { window.removeEventListener('resize', update); }); return { isMobile }; }