No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    QDrawer - Set width based on breakpoint

    Framework
    3
    8
    1386
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nniclas last edited by

      Is there a way to set another width for small screens?
      My use case is I need a fixed width for desktop and 100% width (:width="$q.screen.width) for mobile.

      It seems this cannot be done with media queries?

      1 Reply Last reply Reply Quote 0
      • Allan-EN-GB
        Allan-EN-GB Admin last edited by Allan-EN-GB

        Take a look at the docs: https://quasar.dev/layout/drawer#QDrawer-API

        Look for breakpoint, show-if-above is also relevant.

        1 Reply Last reply Reply Quote 0
        • N
          nniclas last edited by

          As i understand it, :breakpoint defines from where mobile mode is active but is it possible to set full width in mobile mode only?

          1 Reply Last reply Reply Quote 0
          • Allan-EN-GB
            Allan-EN-GB Admin last edited by

            Set the drawer to full width? AFAIK it’s already only full width on mobile …

            1 Reply Last reply Reply Quote 0
            • metalsadman
              metalsadman last edited by metalsadman

              @nniclas get the width of your viewport store it in a data model and use that in qdrawer’s width prop. Computed prop should work too. https://quasar.dev/quasar-utils/dom-utils#Get-Height-%2F-Width or this to get sizes of screen or element https://quasar.dev/vue-components/resize-observer#Introduction.

              1 Reply Last reply Reply Quote 0
              • N
                nniclas last edited by nniclas

                @Allan-EN-GB so I thought, but actually not setting the :width will default the drawer to 300px regardless. (using v1.1.0)
                you are able to use :width="$q.screen.width for full screen width
                my issue is that it would be nice to set the width from a condition based on screen size

                @metalsadman thanks seems like a good pointer, I will look into this

                1 Reply Last reply Reply Quote 0
                • Allan-EN-GB
                  Allan-EN-GB Admin last edited by Allan-EN-GB

                  Can’t you just do: :width="$q.platform.is.desktop ? '300px' : $q.screen.width"

                  If it needs to be more complicated then you can use Aldrins suggestion.

                  1 Reply Last reply Reply Quote 0
                  • N
                    nniclas last edited by

                    That will suffice for this case, I was not aware it was this easy to use conditionals in a view, thank you!

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post