Black Friday: 50% off all products for the first 50 customers. Only 10 left. Use code
40/50 claimed
See pricing →
November 15, 2026

Quasar Visibility Classes: Hide and Show by Screen

Quasar visibility classes in practice: gt-sm, lt-md and xs for screen sizes, desktop-only and mobile-only for platforms, and the pitfalls of each.
Quasar
CSS
Responsive
Mobile

Quasar visibility classes hide or show an element with nothing but a class name: gt-sm to show navigation links from tablet-landscape width up, lt-md for the menu button that replaces them, desktop-only for a keyboard shortcut hint. They work before any JavaScript runs, which makes them the right default for responsive markup. They also have sharp edges: some react to the window width and some to the device, and a hidden element is still rendered. This post covers both kinds, when to reach for $q.screen instead, and the mistakes worth avoiding. All of it is checked against the Quasar 2.35.2 CSS.

Two kinds of Quasar visibility classes

KindExamplesDecided byChanges when
Sizexs, gt-sm, lt-mdWindow width (media queries)You resize the window
Platformdesktop-only, mobile-hide, touch-onlyThe device, through classes Quasar adds to <body>Not when you resize

They're often treated as the same thing ("hide on mobile"), and that's the first pitfall. A narrow desktop window is xs and desktop at the same time.

Size-based classes: xs, gt-sm, lt-md

The size classes use the five Quasar breakpoints:

BreakpointFromTo
xs0px599.98px
sm600px1023.98px
md1024px1439.98px
lg1440px1919.98px
xl1920pxno limit

How the thresholds work, what $q.screen reports and how to change the numbers is the topic of the Quasar breakpoints post. Here we need the class names built on them:

ClassVisible on
xs, sm, md, lg, xlThat one breakpoint only
lt-smxs
lt-mdxs, sm (below 1024px)
lt-lgxs, sm, md
lt-xleverything below 1920px
gt-xssm and up (600px and wider)
gt-smmd and up (1024px and wider)
gt-mdlg and up
gt-lgxl

lt reads "lower than" and gt reads "greater than". The pair you'll use most is gt-sm and lt-md: they split the same line at 1024px, so exactly one of them is visible at any width.

<template>
  <q-toolbar>
    <q-btn class="lt-md" flat round icon="menu" aria-label="Open menu" @click="drawer = true" />
    <q-toolbar-title shrink>Acme</q-toolbar-title>

    <div class="gt-sm row q-gutter-sm q-ml-md">
      <q-btn flat no-caps label="Product" to="/product" />
      <q-btn flat no-caps label="Pricing" to="/pricing" />
      <q-btn flat no-caps label="Docs" to="/docs" />
    </div>

    <q-space />
    <q-btn unelevated color="primary" no-caps label="Sign up" to="/signup" />
  </q-toolbar>
</template>

Under the hood each class is a media query that sets display: none !important outside its range. Inside its range the class adds nothing, so the element keeps its own display: the row above is still a flex container from 1024px up.

Don't confuse them with grid breakpoints

The size classes use the same names as the grid (col-md-6), but they read differently. col-md-6 means "from md up". The class md on its own means "only on md", so it disappears again at 1440px. If you want "from md up", that's gt-sm. When in doubt, open the Breakpoint Visualizer, resize the window, and read its visibility classes panel, which marks each of xs to xl, lt-* and gt-* as showing or hiding at the current width. It also works the other way: pick the sizes an element should appear on and it writes the class.

hidden and invisible

Two more classes don't depend on the screen at all. hidden sets display: none, so the element takes no space. invisible sets visibility: hidden, so it keeps its space but can't be seen. invisible is the one for keeping a layout from jumping, like reserving room for a spinner.

Platform classes: desktop-only, mobile-only and more

Quasar's Platform detection adds classes to <body> (on the server too, from the user agent): desktop or mobile, touch or no-touch, and on matching platforms platform-ios, platform-android, electron, cordova, capacitor, native-mobile and within-iframe. The platform classes key off those:

Show only onHide on
desktop-onlydesktop-hide
mobile-onlymobile-hide
touch-onlytouch-hide
platform-ios-only, platform-android-onlyplatform-ios-hide, platform-android-hide
native-mobile-only, cordova-only, capacitor-onlynative-mobile-hide, cordova-hide, capacitor-hide
electron-onlyelectron-hide
within-iframe-onlywithin-iframe-hide

Use them for things that depend on the device, not the space available:

<template>
  <div class="text-caption text-grey-7">
    <span class="desktop-only">Press <kbd>Ctrl</kbd> + <kbd>K</kbd> to search</span>
    <span class="mobile-only">Tap the search icon to search</span>
  </div>

  <q-btn class="capacitor-hide" flat no-caps label="Get the app" href="/app" />
</template>

The keyboard hint is a good fit: a phone has no Ctrl key however wide it is, and a desktop browser does however narrow. The "Get the app" button hides itself inside your own Capacitor build.

Mobile is the browser, not the width

desktop and mobile come from the user agent. A laptop with a small window is still desktop, so mobile-only never shows there. That's why "hide on mobile" for layout reasons should be a size class (gt-xs or gt-sm), and "hide on mobile" for capability reasons a platform class.

Two cases to know:

  • iPad in desktop mode. iPadOS Safari asks for desktop sites by default, so its user agent looks like a Mac. Quasar corrects this in the browser (a Mac user agent with touch support is treated as iOS), but a server-rendered page is built from the raw user agent. On the first paint an iPad can get desktop, and the classes switch once the app starts.
  • Touch laptops. A Windows laptop with a touchscreen is desktop and touch. touch-only shows there, mobile-only doesn't.

Pitfalls of Quasar visibility classes

A hidden element is still rendered

gt-sm and lt-md don't remove anything; both versions are in the DOM and the inactive one is hidden with CSS. That's harmless for a menu button. It's a problem when:

  • The element is expensive. A chart, a map or a q-table with hundreds of rows rendered twice, once for mobile and once for desktop.
  • It runs side effects. Both copies mount, so both fetch data, start timers or register keyboard shortcuts.
  • It holds form state. Two q-inputs bound to the same model, one hidden, both validated by the surrounding q-form.
  • It needs a unique id. Two copies, two identical ids.

For those, render only one copy with v-if and $q.screen:

<script setup lang="ts">
import { useQuasar } from 'quasar'

const $q = useQuasar()
</script>

<template>
  <SalesChart v-if="$q.screen.gt.sm" />
  <SalesSummaryList v-else />
</template>

The trade-off: with server rendering, $q.screen reports xs until the app has hydrated, so the server HTML contains the mobile version and desktop visitors see the swap. Put v-if switches below the fold, or accept the swap, and keep CSS classes for everything visible on the first paint.

display: none removes it for screen readers too

A hidden element is out of the tab order and the accessibility tree, which is usually what you want. But it means the two versions must carry the same information. If the desktop header has a "Docs" link and the mobile drawer doesn't, mobile and screen reader users at that width lose it.

The !important wins

The hiding rule uses !important. If an element has lt-md and you set display: flex on it yourself, it still disappears from 1024px up. To change that, change the class, not the specificity.

Don't hide layout pieces with classes

q-drawer, q-header and q-footer take part in the q-layout size calculations. Hiding a drawer with gt-sm hides its content, but the layout can still reserve space for it. Use the drawer's own props instead (breakpoint, show-if-above, behavior), and visibility classes for the content inside.

Orientation and print classes

Two smaller groups complete the set:

  • orientation-portrait and orientation-landscape use the orientation media query, which compares the window's height and width.
  • print-only and print-hide show or hide content when the page is printed. print-hide on the header, drawer and action buttons gives you a clean printout of an invoice page without a print stylesheet.

Common questions about Quasar visibility classes

How do I hide something on mobile in Quasar? For small screens, use gt-xs (hidden below 600px) or gt-sm (hidden below 1024px). For mobile devices whatever their width, use mobile-hide.

What is the difference between gt-sm and lt-md? They're opposites: gt-sm shows from 1024px up and lt-md below 1024px.

Why is my lt-md element still visible on a desktop? Check the window width, not the screen. A desktop window narrower than 1024px is sm, so lt-md applies. The Breakpoint Visualizer shows the current width and breakpoint.

Can I use v-show with $q.screen instead? You can, but it combines the downsides: both copies are rendered and the visibility still waits for JavaScript. Use a class or v-if.

Next step

Keep the Breakpoint Visualizer open while you add visibility classes. Drag the window across 600px, 1024px and 1440px and you'll see exactly which breakpoint, and so which classes, apply at each width.