Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify add class on certain grid size

I'm trying to only add a class to the v-flex if the grid size of the element is xs (so only on mobile). The code below shows the thought process behind it. However this doesn't work, so how can I apply a class that only on a certain grid size?

   <v-flex xs12 lg6 :class="{'roomPadding': xs != visible }">
      <p> My room </p>
   </v-flex>
like image 794
Otto Avatar asked Jun 28 '18 11:06

Otto


1 Answers

use breakpoint:

:class="{'roomPadding': $vuetify.breakpoint.xs}"

See docs about breakpoint object and visibility

If you want to apply the class to every breakpoint (i.e. screen-size) except xs, you can use:

:class="{'roomPadding': !$vuetify.breakpoint.xs}" (notice !)
or
:class="{'roomPadding': $vuetify.breakpoint.smAndUp}"

because breakpoints return boolean value.
You can get current breakpoint name (string) with vuetify.breakpoint.name

like image 129
Traxo Avatar answered Nov 20 '22 01:11

Traxo