--- category: Browser --- # useBreakpoints Reactive viewport breakpoints. ## Usage ```ts import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'; const breakpoints = useBreakpoints(breakpointsTailwind); const smAndLarger = breakpoints.greaterOrEqual('sm'); // sm and larger const largerThanSm = breakpoints.greater('sm'); // only larger than sm const lgAndSmaller = breakpoints.smallerOrEqual('lg'); // lg and smaller const smallerThanLg = breakpoints.smaller('lg'); // only smaller than lg ``` ```vue ``` #### Server Side Rendering and Nuxt If you are using `useBreakpoints` with SSR enabled, then you need to specify which screen size you would like to render on the server and before hydration to avoid an hydration mismatch ```ts import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'; const breakpoints = useBreakpoints(breakpointsTailwind, { ssrWidth: 768, // Will enable SSR mode and render like if the screen was 768px wide }); ``` Alternatively you can set this up globally for your app using [`provideSSRWidth`](../useSSRWidth/index.md) ## Presets - Tailwind: `breakpointsTailwind` - Bootstrap v5: `breakpointsBootstrapV5` - Vuetify v2: `breakpointsVuetifyV2` (deprecated: `breakpointsVuetify`) - Vuetify v3: `breakpointsVuetifyV3` - Ant Design: `breakpointsAntDesign` - Quasar v2: `breakpointsQuasar` - Sematic: `breakpointsSematic` - Master CSS: `breakpointsMasterCss` - Prime Flex: `breakpointsPrimeFlex` - ElementUI / ElementPlus: `breakpointsElement` _Breakpoint presets are deliberately not auto-imported, as they do not start with `use` to have the scope of VueUse. They have to be explicitly imported:_ ```js import { breakpointsTailwind } from '@vueuse/core'; // and so on ``` ## Type Declarations ```ts export * from './breakpoints'; export type Breakpoints = Record>; export interface UseBreakpointsOptions extends ConfigurableWindow { /** * The query strategy to use for the generated shortcut methods like `.lg` * * 'min-width' - .lg will be true when the viewport is greater than or equal to the lg breakpoint (mobile-first) * 'max-width' - .lg will be true when the viewport is smaller than the xl breakpoint (desktop-first) * * @default "min-width" */ strategy?: 'min-width' | 'max-width'; ssrWidth?: number; } /** * Reactively viewport breakpoints * * @see https://vueuse.org/useBreakpoints * * @__NO_SIDE_EFFECTS__ */ export declare function useBreakpoints( breakpoints: Breakpoints, options?: UseBreakpointsOptions, ): Record> & { greaterOrEqual: (k: MaybeRefOrGetter) => ComputedRef; smallerOrEqual: (k: MaybeRefOrGetter) => ComputedRef; greater(k: MaybeRefOrGetter): ComputedRef; smaller(k: MaybeRefOrGetter): ComputedRef; between(a: MaybeRefOrGetter, b: MaybeRefOrGetter): ComputedRef; isGreater(k: MaybeRefOrGetter): boolean; isGreaterOrEqual(k: MaybeRefOrGetter): boolean; isSmaller(k: MaybeRefOrGetter): boolean; isSmallerOrEqual(k: MaybeRefOrGetter): boolean; isInBetween(a: MaybeRefOrGetter, b: MaybeRefOrGetter): boolean; current: () => ComputedRef; active(): ComputedRef<'' | K>; }; export type UseBreakpointsReturn = ReturnType>; ```