How do you create typical layouts in the the most popular Material Design styling libraries for Vue?
Creating layouts for your application
Layouts help us standardize UI across the application.
For e.g., you have layouts to take care of -
Toolbar for the app and for views/components
Navigation bars
Standard controls (buttons/titles etc.) for list or detail views
.. and so on.
Vuetify and Quasar allow you to do your own thing, but I find the below way of creating layouts easiest.
Vuetify
Vuetify is an amazing library and we choose Vuetify for client projects most of the times if material design standards are agreeable.
I typically do not end up using layouts in Vue router when using Vuetify. - I should, but found it harder to reuse. Instead I use layouts like a beginner would.
Create layouts
Create a new folder - components/layouts in your Vue project.
Quasar framework is often compared against Vuetify since both of them implement Material Design guidelines. Quasar provides a more controlled ecosystem that can make you productive on web/desktop/mobile UI development and also provide “more useful” components. [not starting a war here - this is my opinion and I am entitled to have a stupid opinion].
Quasar provides an out-of-the-box way of using layouts in router.
One of my main mottos in life happens to be “Do not fight frameworks” - so I just follow “the way”.
Create layouts
Creating layouts is similar to what we did in Vuetify, but we don’t use slots in the same way, and we have a different folder structure.
We create a MainLayout.vue which serves the layout -
<!-- ./src/layouts/MainLayout.vue --><template><q-layoutview="lHh Lpr lFf"><q-headerelevated><q-toolbar><q-btnflatdenseroundicon="menu"aria-label="Menu"@click="leftDrawerOpen = !leftDrawerOpen"/><q-toolbar-title>Mostart</q-toolbar-title><spanclass="self-right"><q-btnflatfabto="/settings"><q-iconname="settings"/></q-btn><q-btnflatfabto="/help"><q-iconname="help"/></q-btn></span></q-toolbar></q-header><q-drawerv-model="leftDrawerOpen"show-if-aboveborderedcontent-class="bg-grey-1"><q-list><q-item-labelheaderclass="text-grey-8">Options</q-item-label><!-- This is just a link --><EssentialLinkv-for="link in essentialLinks":key="link.title"v-bind="link"/></q-list><q-list><!-- <EssentialLink v-bind="setupLink" /> --><q-separator/><EssentialLinkv-bind="helpLink"/><q-separator/><EssentialLinkv-bind="exitLink"/></q-list></q-drawer><q-page-container><router-view/></q-page-container></q-layout></template><!-- Removed to keep this condensed -->
Keep things in control - see related components in one place
Multiple, dynamic layouts based on data is easy to implement and comprehend
Nothing in Quasar prevents us from having the same layout style as in Vuetify, but the framework does provide a clean abstraction for standard applications and UI structure.