Tabs
Quasar Tabs are a way of displaying more information using less window real-estate. This Component can especially be used in Layouts.
On desktop, Tabs will use clickable arrows to indicate to the user that they can scroll to see them all, if they don’t all fit on the screen. Tabs are responsive and on small screens (like on a phone) if they can all fit on the screen they will share all screen width, otherwise user can swipe through the Tabs.
Basic Usage
A basic example of Tabs (they are more complex as you will see in next sections where you’ll learn to use Vue Routes or v-model
with it):
The name
attribute on <q-tab>
s links this Tab to the DOM element using a Vue reference with same name.
As you can see, we have a container (<q-tabs>
) and Tabs themselves (<q-tab>
). Let’s dissect each:
Tabs Container Component
Use <q-tabs>
component to wrap your Tabs.
Vue Properties
Vue Property | Type | Description |
---|---|---|
refs | Object | (Required) Tell component which Vue $refs object to use for its targets. |
default-tab | String | Default Tab to be selected. Do not use it along with v-model . |
Supports
v-model
which holds the active Tab’s name. When usingv-model
it’s pointless to also usedefault-tab
property, since you can initialize the model with a name.
Vue Methods
Vue Method | Description |
---|---|
setActiveTab(name) | Set active Tab using its name. |
Vue Events
Event | Description |
---|---|
@change | Triggered whenever selected Tab changes. |
Tab Component
Vue Properties
Vue Property | Type | Description |
---|---|---|
name | String | Configure a name for tab. This name is used to find $refs as target too. |
label | String | Label to use. |
icon | String | Icon to use. |
disable | Boolean | If disabled user won’t be able to select it. |
hidden | Boolean | Hide it.. or not. |
hide | String | Possible values: icon or label . On narrow screens one of the two will be hidden. |
Supports
v-model
which holds the active Tab’s name. When usingv-model
it’s pointless to also usedefault-tab
property, since you can initialize the model with a name.
If using routes for each Tab:
Vue Property | Type | Description |
---|---|---|
route | String | Configure Vue Route “to” property. |
label | String | Label to display. |
icon | String | Icon to display. |
replace | Boolean | Configure Vue Router to replace current route rather than push a new one. |
exact | Boolean | Exact match of the route, just as described for <router-link> . |
append | Boolean | Append route to current one, just as described for <router-link> . |
disable | Boolean | If disabled user won’t be able to select it. |
hidden | Boolean | Hide it.. or not. |
hide | String | Possible values: icon or label . On narrow screens one of the two will be hidden. |
Either use a
route
or aname
, but not both.
Vue Methods
Vue Method | Description |
---|---|
activate() | Make this Tab the selected one. |
deactivate() | Unselect this Tab as the active one. |
setTargetVisibility(Bool) | Sets the target as visible (true) or hides it (false). |
Vue Events
Event | Description |
---|---|
@selected | Triggered whenever Tab is selected. |
Usage with Vue Router
|
Your Tabs will be auto-selected when user navigates to the specified routes.
Usage with “v-model”
Best way to programmatically switch between Tabs is by using a v-model
:
Usage on a Layout
|
Notice the slot="navigation"
attribute. This makes Quasar know where to place your Tabs depending on the theme. On Material Design theme it will place them between Layout header and page view, and on iOS theme between page view and Layout footer.
Coloring
Use one of the Quasar colors from the Color Palette, like primary
, secondary
, orange
, teal
as CSS class:
You can also invert the colors (see demo for example) by adding the color and inverted
as CSS classes:
Always Justified Alignment
By default, on large width windows the Tabs get aligned to the left. If you wish to maintain a justified alignment (filling all available space on the width), then add justified
CSS class on the Tabs: