Quasar Cards are a great way to display important pieces of content, and are quickly emerging as a core design pattern for Apps. They’re a great way to contain and organize information, while also setting up predictable expectations for the user. With so much content to display at once, and often so little screen real-estate, Cards have fast become the design pattern of choice for many companies, including the likes of Google and Twitter.
Quasar Cards are a collection of components that you can use, based on the needs. It’s all about being creative. Experiment with different Web Components by embedding them in Card components to create awesome results.
Familiarize yourself with Card components with the examples below. The only requirement is that QCard needs to wrap all the other ones. Everything else is optional and can be inserted into your template anywhere as long as they are direct children of QCard.
Following are Vue properties of QCard component:
Vue Property
Type
Description
square
Boolean
Squared borders instead of round ones.
flat
Boolean
Remove shadow.
inline
Boolean
Make it inline. Also set a CSS width to work. Take a look at Grid example on the “More Examples” section.
QCardTitle has three main areas (all are optional): title, subtitle (“subtitle” slot) and right side (“right” slot).
Note that you can set title and subtitle as overlay on an image or video through a QCardMedia component too (see QCardMedia section).
<q-card-title> <!-- Optional. Anything that goes here without specifying "slot" is considered the main title --> Title
<!-- Optional. Adding the subtitle. Notice slot="subtitle" --> <spanslot="subtitle">Subtitle</span>
<!-- Optional. Adding something on the right side, like an icon triggering a Popover with a menu. Notice the slot="right" --> <q-iconslot="right"name="more_vert"> <q-popover> <q-listlinkclass="no-border"> <q-itemv-close-overlay> <q-item-mainlabel="Remove Card" /> </q-item> <q-itemv-close-overlay> <q-item-mainlabel="Send Feedback" /> </q-item> <q-itemv-close-overlay> <q-item-mainlabel="Share" /> </q-item> </q-list> </q-popover> </q-icon> </q-card-title>
Card Main Content (QCardMain)
QCardMain defines an area containing the main Card content, like description, details or anything you need outside of the other Card component’s purpose.
<q-card-main> Card main content. </q-card-main>
<q-card-main> <p>$・Italian, Cafe</p> <pclass="text-faded"> Small plates, salads & sandwiches in an intimate setting. </p> </q-card-main>
Card Actions (QCardActions)
Cards can have some actions (buttons) attached to them.
Vue Property
Type
Description
vertical
Boolean
Stack actions vertically
align
String
One of ‘start’, ‘center’, ‘end’, ‘around’, ‘between’ which aligns buttons in respect to the actions container
<!-- Horizontal actions --> <q-card-actions> <!-- Define the buttons to your liking, these are just examples --> <q-btnflatrounddenseicon="event" /> <q-btnflatlabel="5:30PM" /> <q-btnflatlabel="7:30PM" /> <q-btnflatlabel="9:00PM" /> <q-btnflatcolor="primary"label="Reserve" /> </q-card-actions>
Cards can also contain media elements: images, videos (through QVideo) or a parallax (through QParallax). This can be done through QCardMedia component, which supports an optional overlay too (for things like title and/or subtitle).
Vue Property
Type
Description
overlay-position
String
One of ‘top’, ‘bottom’ or ‘full’ which sets the position of overlay on top of media element.
<!-- Displaying an image --> <q-card-media> <imgsrc="~assets/some-image.jpg"> </q-card-media>
<!-- Display a video (with help of QVideo component) --> <q-card-media> <q-videosrc="https://www.youtube.com/embed/k3_tw44QsZQ?rel=0" /> </q-card-media>
<!-- Displaying a Parallax (with help of QParallax) --> <q-card-media> <q-parallax:src="'statics/parallax1.jpg'":height="150"> <divslot="loading">Loading...</div> </q-parallax> </q-card-media>
Now let’s see how we can add overlays too (through “overlay” slot):
<q-card-media> <imgsrc="~assets/mountains.jpg">
<!-- Notice the slot="overlay" --> <q-card-titleslot="overlay"> Title <spanslot="subtitle">Subtitle</span> </q-card-title> </q-card-media>
<!-- Overlay at top of media elements. Notice overlay-position="top" --> <q-card-mediaoverlay-position="top"> <imgsrc="~assets/mountains.jpg">
<!-- Notice the slot="overlay" --> <q-card-titleslot="overlay"> Title <spanslot="subtitle">Subtitle</span> </q-card-title> </q-card-media>
<!-- Overlay on full area of media elements Notice overlay-position="full" --> <q-card-mediaoverlay-position="full"> <imgsrc="~assets/mountains.jpg">
<!-- Notice the slot="overlay" --> <q-card-titleslot="overlay"> Title <spanslot="subtitle">Subtitle</span> </q-card-title> </q-card-media>
Card Inner Separator
You can choose to add a separator between Card components, which is basically a horizontal thin line, by adding QCardSeparator.
Vue Property
Type
Description
inset
Boolean
Inset separator
<q-card> <q-card-title> ... </q-card-title>
<!-- Here is the separator --> <q-card-separator />
Place a QList with its QItems at root of your QCard, like this:
<q-card> ... <q-list> <q-item> <q-item-side> <q-item-tilecolor="primary"icon="local bar" /> </q-item-side> <q-item-main> <q-item-tilelabel>Bar XYZ</q-item-tile> <q-item-tilesublabel>Have a drink.</q-item-tile> </q-item-main> </q-item> <q-item> <q-item-side> <q-item-tilecolor="red"icon="local gas station" /> </q-item-side> <q-item-main> <q-item-tilelabel>Gas Station</q-item-tile> <q-item-tilesublabel>Fill your gas tank.</q-item-tile> </q-item-main> </q-item> <q-item> <q-item-side> <q-item-tilecolor="amber"icon="local movies" /> </q-item-side> <q-item-main> <q-item-tilelabel>Cinema XYZ</q-item-tile> <q-item-tilesublabel>Watch a movie.</q-item-tile> </q-item-main> </q-item> </q-list> ... </q-card>
There’s also the possibility to create a nice header for your Cards with an image / avatar, a person name and some quick details. In this example, we skip using QCardList:
In order to make a grid of Cards you need to use the inline property of QCard component and set a width for your Cards.
<div> <!-- In this example every card has a "style" tag with a width. Consider defining a CSS class instead to ease the template syntax. --> <q-cardinlinestyle="width: 300px">...</q-card> <q-cardinlinestyle="width: 300px">...</q-card> <q-cardinlinestyle="width: 300px">...</q-card> ... <q-cardinlinestyle="width: 300px">...</q-card> </div>
Card with Collapsibles
Since Collapsibles are List items too, it makes sense to use a QList component to encapsulate them. Also, imagine a Card with Collapsibles containing Cards. Inception :)
<q-card> <q-card-title> Card with Collapsible List </q-card-title>
<q-card-separator />
<q-list> <q-collapsibleicon="explore"label="First"> <div> Lorem ipsum dolor sit amet... </div> </q-collapsible>
<q-collapsibleicon="perm_identity"label="Second"> <div> Lorem ipsum dolor sit amet... </div> </q-collapsible>
<q-collapsibleicon="shopping_cart"label="Third"> <div> Lorem ipsum dolor sit amet... </div> </q-collapsible> </q-list> </q-card>