Card
A card is a UI design pattern that groups related information in a flexible-size container visually resembling a playing card
import { VCard } from '@vonage/vivid-api-vue';<template> <VCard headline="I'm a card"></VCard></template>
<script setup lang="ts"> import {VCard} from '@vonage/vivid-api-vue';</script>import { registerCard } from '@vonage/vivid-api';
registerCard('your-prefix');<script type="module"> import { registerCard } from '@vonage/vivid-api'; registerCard('your-prefix');</script>
<your-prefix-card headline="I'm a card"></your-prefix-text-card>This is the slot for any content that you need to display after header content (Headline, Subtitle). It can be used instead of, or in conjunction with the text attribute.
<script setup lang="ts">import { VCard, VTable, VTableHead, VTableBody, VTableRow, VTableCell, VTableHeaderCell } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Vivid Card Component (headline)" subtitle="Extra text below the card headline (subtitle)"> <template #body> <VTable> <VTableHead> <VTableRow> <VTableHeaderCell>Name</VTableHeaderCell> <VTableHeaderCell>Job Title</VTableHeaderCell> </VTableRow> </VTableHead> <VTableBody> <VTableRow> <VTableCell>Marty McFly</VTableCell> <VTableCell>Student</VTableCell> </VTableRow> <VTableRow> <VTableCell>Dr Emit Brown</VTableCell> <VTableCell>Scientist</VTableCell> </VTableRow> </VTableBody> </VTable> </template> </VCard></template><vwc-card headline="Vivid Card Component (headline)" subtitle="Extra text below the card headline (subtitle)"> <vwc-table slot="body"> <vwc-table-head> <vwc-table-row> <vwc-table-header-cell>Name</vwc-table-header-cell> <vwc-table-header-cell>Job Title</vwc-table-header-cell> </vwc-table-row> </vwc-table-head> <vwc-table-body> <vwc-table-row> <vwc-table-cell>Marty McFly</vwc-table-cell> <vwc-table-cell>Student</vwc-table-cell> </vwc-table-row> <vwc-table-row> <vwc-table-cell>Dr Emit Brown</vwc-table-cell> <vwc-table-cell>Scientist</vwc-table-cell> </vwc-table-row> </vwc-table-body> </vwc-table></vwc-card>The icon slot is the preferred way to add an icon to the component. Use it to display an icon from the icon library.
<script setup lang="ts">import { VCard, VIcon } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Vivid Card Component" subtitle="Extra text below the card headline"> <template #icon><VIcon name="chat-line" /></template> </VCard></template><vwc-card headline="Vivid Card Component" subtitle="Extra text below the card headline"> <vwc-icon slot="icon" name="chat-line"></vwc-icon></vwc-card>Use the graphic slot for Icons or custom images.
The graphic slot overrides the icon slot.
<script setup lang="ts">import { VCard, VBrand } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Vivid Card Component" subtitle="Extra text below the card headline"> <template #graphic> <VBrand name="android" variant="mono" style="font-size: 44px; color: #A4C439"></VBrand> </template> </VCard></template><vwc-card headline="Vivid Card Component" subtitle="Extra text below the card headline"> <vwc-icon slot="graphic" name="android-mono" style="font-size: 44px; color: #A4C439"></vwc-icon></vwc-card>The media slot can be used to display images or video content above the card header.
<script setup lang="ts">import { VCard } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Card with Media Slot" subtitle="Extra text below the card headline" class="card-media"> <template #media> <img src="https://doodleipsum.com/300x150/flat?bg=EB765D&i=7d5ed3bc0c215d1359b2a63d03cf1540" alt="Sitting on Floor" style="width: 100%; height: 150px; object-fit: cover;" /> </template> </VCard></template>
<style scoped>.card-media { max-inline-size: 300px;}</style><vwc-card headline="Card with Media Slot" subtitle="Extra text below the card headline" class="card-media"> <img slot="media" src="https://doodleipsum.com/300x150/flat?bg=EB765D&i=7d5ed3bc0c215d1359b2a63d03cf1540" alt="Sitting on Floor" style="width: 100%; height: 150px; object-fit: cover;" /></vwc-card>
<style> .card-media { max-inline-size: 300px; }</style>The meta slot is for action content in the card header.
<script setup lang="ts">import { VCard, VMenu, VMenuItem, VButton, VIcon } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Card with Meta Slot" subtitle="Extra text below the card headline"> <template #meta> <VMenu aria-label="Card options" placement="bottom-start"> <VButton slot="anchor" aria-label="Open menu" appearance="outlined"> <template #icon><VIcon name="more-vertical-line"></VIcon></template> </VButton> <VMenuItem text="save card"></VMenuItem> <VMenuItem text="remove card"></VMenuItem> </VMenu> </template> </VCard></template><vwc-card headline="Card with Meta Slot" subtitle="Extra text below the card headline"> <div slot="meta"> <vwc-menu aria-label="Card options" placement="bottom-start"> <vwc-button slot="anchor" aria-label="Open menu" appearance="outlined"> <vwc-icon slot="icon" name="more-vertical-line"></vwc-icon> </vwc-button> <vwc-menu-item text="save card"></vwc-menu-item> <vwc-menu-item text="remove card"></vwc-menu-item> </vwc-menu> </div></vwc-card>The footer slot is for content in the card footer.
Use it for adding buttons or action items.
By default - items inside footer slot are aligned to the end.
<script setup lang="ts">import { VCard, VButton, VIcon } from '@vonage/vivid-api-vue';</script>
<template> <VCard headline="Card with Footer Slot" subtitle="Extra text below the card headline"> <template #footer> <VButton shape="pill" label="Action" appearance="outlined" icon-trailing> <template #icon><VIcon name="arrow-bold-right-line"></VIcon></template> </VButton> </template> </VCard></template><vwc-card headline="Card with Footer Slot" subtitle="Extra text below the card headline"> <vwc-button slot="footer" shape="pill" label="Action" appearance="outlined" icon-trailing> <vwc-icon slot="icon" name="arrow-bold-right-line"></vwc-icon> </vwc-button></vwc-card>Card has predefined content style template.
Use the main slot to fully override a card’s predefined template with your own. When using main - only appearance and elevation are applied on the card.
<script setup lang="ts">import { VCard, VLayout } from '@vonage/vivid-api-vue';</script>
<template> <VCard> <template #main> <VLayout gutters="small"> Assign custom template using "main" slot. </VLayout> </template> </VCard></template><vwc-card> <vwc-layout gutters="small" slot="main"> {' '} Assign custom template using "main" slot.{' '} </vwc-layout></vwc-card>The card border color can be customized using --card-border-color.
Note: this variable works only with outlined appearance.
<script setup lang="ts">import { VCard } from '@vonage/vivid-api-vue';</script>
<template> <VCard class="vwc-card" appearance="outlined" headline="Card with a custom border color" /></template>
<style scoped>.vwc-card { --card-border-color: #30a849; max-inline-size: 42ch;}</style><vwc-card class="vwc-card" appearance="outlined" headline="Card with a custom border color"></vwc-card>
<style> .vwc-card { --card-border-color: #30a849; max-inline-size: 42ch; }</style>The card headline can be trimmed to your preferable number of lines.
The number of lines is controlled by the css variable --headline-line-clamp.
<script setup lang="ts">import { VCard } from '@vonage/vivid-api-vue';</script>
<template> <VCard class="vwc-card" headline="Card with long headline that has trim into one line"></VCard></template>
<style scoped>.vwc-card { --headline-line-clamp: 1; max-inline-size: 42ch;}</style><vwc-card class="vwc-card" headline="Card with long headline that has trim into one line"></vwc-card>
<style> .vwc-card { --headline-line-clamp: 1; max-inline-size: 42ch; }</style>The card subtitle can be trimmed to your preferable number of lines.
The number of lines is controlled by css variable --subtitle-line-clamp.
<script setup lang="ts">import { VCard } from '@vonage/vivid-api-vue';</script>
<template> <VCard class="vwc-card" headline="Card with Trimmed Subtitle" subtitle="This subtitle is extremely long and will be trimmed after 2 lines. This way you can control the size of the card."></VCard></template>
<style scoped>.vwc-card { --subtitle-line-clamp: 2; max-inline-size: 42ch;}</style><vwc-card class="vwc-card" headline="Card with Trimmed Subtitle" subtitle="This subtitle is extremely long and will be trimmed after 2 lines. This way you can control the size of the card."></vwc-card>
<style> .vwc-card { --subtitle-line-clamp: 2; max-inline-size: 42ch; }</style>| Property | Type | Default | Description |
|---|---|---|---|
| appearance | 'ghost' | 'outlined' | 'elevated' | Sets the element's appearance. | |
| clickableCard | boolean | Indicates whether card should be a clickable <button> element. | |
| download | string | Prompts the user to save the linked URL. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| elevation | 0 | 2 | 4 | 8 | 12 | 16 | 24 | Sets the element's elevation. | |
| headline | string | Sets the element's headline. | |
| href | string | The URL the hyperlink references. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| hreflang | string | Hints at the language of the referenced resource. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| ping | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| referrerpolicy | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| rel | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| subtitle | string | Sets the element's subtitle. | |
| target | '_self' | '_blank' | '_parent' | '_top' | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| text | string | Sets the element's text. | |
| type | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. |
| Property | Type | Default | Description |
|---|---|---|---|
| appearance | 'ghost' | 'outlined' | 'elevated' | Sets the element's appearance. | |
| clickable-card | boolean | Indicates whether card should be a clickable <button> element. | |
| download | string | Prompts the user to save the linked URL. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| elevation | 0 | 2 | 4 | 8 | 12 | 16 | 24 | Sets the element's elevation. | |
| headline | string | Sets the element's headline. | |
| href | string | The URL the hyperlink references. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| hreflang | string | Hints at the language of the referenced resource. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| ping | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| referrerpolicy | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| rel | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| subtitle | string | Sets the element's subtitle. | |
| target | '_self' | '_blank' | '_parent' | '_top' | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| text | string | Sets the element's text. | |
| type | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. |
| Name | Description |
|---|---|
| body | The body slot is for the main content of the card. Displayed between the header and footer content. |
| footer | The footer slot is for content in the card footer. |
| graphic | The graphic slot overrides the icon slot. |
| icon | The preferred way to add an icon to the component. |
| main | Assign nodes to main slot to fully override a card's predefined flow and style with your own. |
| media | The media slot is mainly for images or video content above the card header. |
| meta | The meta slot is for action content in the card header. |
| Name | Description |
|---|---|
| body | The body slot is for the main content of the card. Displayed between the header and footer content. |
| footer | The footer slot is for content in the card footer. |
| graphic | The graphic slot overrides the icon slot. |
| icon | The preferred way to add an icon to the component. |
| main | Assign nodes to main slot to fully override a card's predefined flow and style with your own. |
| media | The media slot is mainly for images or video content above the card header. |
| meta | The meta slot is for action content in the card header. |