A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. They are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. They have no fixed width to start, so they'll naturally fill the full width of its parent element.
<template><div><divclass="mb-5 grid grid-cols-3 gap-4"><div><AisCardheader="Test Header"footer="Test Footer">This is the body of the card.</AisCard></div><div><AisCardheader="No Footer">This is the body of the card.</AisCard></div><div><AisCard>No header or footer.</AisCard></div></div></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';</script>
Use icon and status props to easily customize your card header. Likewise, you can use footer-icon and footer-status to easily customize your card footer.
Header with icon
This is the body of the card.
Header with status
This is the body of the card.
<template><div><divclass="mb-5 grid grid-cols-3 gap-4"><div><AisCardheader="Header with icon"header-class="font-bold"icon="users"icon-class="text-primary"footer="Footer with icon"footer-class="font-bold":footer-icon="faLandmark"footer-icon-class="text-blue-500">This is the body of the card.</AisCard></div><div><AisCardheader="Header with status"header-class="font-bold"status="busy"status-class="text-blue-500"footer="Footer with status"footer-class="font-bold text-danger"footer-status="error"footer-status-class="animate-pulse">This is the body of the card.</AisCard></div></div></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';import{ faLandmark }from'@fortawesome/free-solid-svg-icons';import{ library }from'@fortawesome/fontawesome-svg-core';
library.add(faLandmark);</script>
Use icon and status props to easily customize your card header. Likewise, you can use footer-icon and footer-status to easily customize your card footer.
Try the different rounded options
This is the body of the card.
<template><div><divclass="grid gap-8"><divclass="flex justify-center"><AisRadioGroupv-model="selectedOption":options="options"name="radios"size="sm"class="rounded"buttonsvariant="default"outline/></div><div><AisCardheader="Try the different rounded options"icon="file"footer="Some Footer"footer-icon="info":rounded="selectedOption">This is the body of the card.</AisCard></div></div></div></template><scriptsetup>import{ ref }from"vue";import{ AisCard }from'@ais-public/ais-components';import{ AisRadioGroup }from'@ais-public/ais-components';const options =ref([{value:'none',label:'rounded-none'},{value:'sm',label:'rounded-sm'},{value:'rounded',label:'rounded'},{value:'md',label:'rounded-md'},{value:'lg',label:'rounded-lg'},{value:'xl',label:'rounded-xl'},{value:'2xl',label:'rounded-2xl'},{value:'3xl',label:'rounded-3xl'},]);const selectedOption =ref('none');</script>
To align the content of the card set the align prop to left, center or right. The default is left.
Left
This is the body of the card.
Center
This is the body of the card.
Right
This is the body of the card.
<template><div><divclass="grid grid-cols-3 gap-4"><div><AisCardheader="Left"footer="Test Footer">This is the body of the card.</AisCard></div><div><AisCardheader="Center"footer="Test Footer"align="center">This is the body of the card.</AisCard></div><div><AisCardheader="Right"footer="Test Footer"align="right">This is the body of the card.</AisCard></div></div></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';</script>
<template><divclass="grid grid-cols-4 gap-4"><div><AisCardheader="Default"variant="default">This is the body of the card.</AisCard></div><div><AisCardheader="Primary"variant="primary">This is the body of the card.</AisCard></div><div><AisCardheader="Secondary"variant="secondary">This is the body of the card.</AisCard></div><div><AisCardheader="Info"variant="info">This is the body of the card.</AisCard></div><div><AisCardheader="Success"variant="success">This is the body of the card.</AisCard></div><div><AisCardheader="Danger"variant="danger">This is the body of the card.</AisCard></div><div><AisCardheader="Warning"variant="warning">This is the body of the card.</AisCard></div><div><AisCardheader="Plain"variant="plain">This is the body of the card.</AisCard></div></div></template><scriptsetup>import{ AisCard }from"@ais-public/ais-components";</script>
<template><divclass="grid grid-cols-4 gap-4"><div><AisCardheader="Default"footer="Footer"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Primary"footer="Footer"variant="primary"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Secondary"footer="Footer"variant="secondary"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Info"footer="Footer"variant="info"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Success"footer="Footer"variant="success"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Danger"footer="Footer"variant="danger"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Warning"footer="Footer"variant="warning"outline>This is the body of the card.</AisCard></div><div><AisCardheader="Plain"footer="Footer"variant="plain"outline>This is the body of the card.</AisCard></div></div></template><scriptsetup>import{ AisCard }from"@ais-public/ais-components";</script>
For custom content use the header and/or footer slots.
Custom Header
This is the body of the card.
Attachments
This is the body of the card.
<template><div><divclass="mb-5 grid grid-cols-2 gap-4"><div><AisCard><template#header><AisIconicon="users"/> <b><spanclass="text-blue-600">Custom</span> Header</b></template>
This is the body of the card.
<template#footer><divclass="text-blue-600"><AisIconicon="info"/>
Footer slot content
</div></template></AisCard></div><div><AisCardfooter-class="text-cyan-600"><template#header><AisIcon:icon="faFile"/> <i>Attachments</i></template>
This is the body of the card.
<template#footer><AisIconicon="info"/>
Footer slot content
</template></AisCard></div></div></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';import{ AisIcon }from'@ais-public/ais-components';import{ faFile }from'@fortawesome/free-regular-svg-icons';import{ library }from'@fortawesome/fontawesome-svg-core';
library.add(faFile);</script>
Or just customize the right side of the header and/or footer with the headerRight and/or footerRight slots.
Standard header
23
This is the body of the card.
<template><divclass="mb-5 grid grid-cols-2 gap-4"><AisCardheader="Standard header"icon="success"footer="Standard footer"footer-icon="info"><template#headerRight><AisBadgevariant="secondary"size="sm">23</AisBadge></template>
This is the body of the card.
<template#footerRight><AisBadgevariant="danger"size="xs">Final</AisBadge></template></AisCard></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';import{ AisBadge }from'@ais-public/ais-components';import{ faFile }from'@fortawesome/free-regular-svg-icons';import{ library }from'@fortawesome/fontawesome-svg-core';
library.add(faFile);</script>
Set the collapsible prop to be able to expand/collapse the card by clicking anywhere on the card header. Set the collapse-arrow boolean prop to have a dynamic leading arrow in your header.
Set the default-open prop to false to have the card start out collapsed. Each click of the header will emit a click event, passing the open state.
Click on the header to expand/collapse the body and footer.
<template><divclass="grid grid-cols-2 gap-4"><div><AisCardheader="Click header to expand/collapse"footer="Test Footer"icon="users"collapsiblecollapse-arrow>Click on the header to expand/collapse the body and footer.</AisCard></div><div><AisCardheader="Click header to expand/collapse"footer="Test Footer"collapsible:default-open="false"@click="handleClick"><template#headerRight="{ open }"><AisIcon:icon="open ? 'caret-up' : 'caret-down'"/></template>
Click on the header to expand/collapse the body and footer.
</AisCard></div></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';import{ AisIcon }from'@ais-public/ais-components';consthandleClick=(e)=>{ console.log(`header.click: open=[${e}]`)}</script>
Use the no-body prop to remove the use of a AisCardBody inside of the card. This can be useful when you want to nest something within a card without any padding or margin, like a table or list group.
For a table with many rows you can nest it with the sticky-headers prop to minimize the overall height of the card. Just wrap your table in a div with a max-height set and overflow-y-auto set.
For a table with many rows you can nest it with the sticky-headers prop to minimize the overall height of the card. Just wrap your table in a div with a max-height set and overflow-y-auto set.
Card with flush list group
List Group Item #1
List Group Item #2
List Group Item #3
List Group Item #4
Card with flush list group and a card body
List Group Item #1
List Group Item #2
List Group Item #3
List Group Item #4
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem.
<template><divclass="grid grid-cols-2 gap-4"><div><AisCardno-bodyheader="Card with flush list group"><AisListGroupflush><AisListGroupItem>List Group Item #1</AisListGroupItem><AisListGroupItem>List Group Item #2</AisListGroupItem><AisListGroupItem>List Group Item #3</AisListGroupItem><AisListGroupItem>List Group Item #4</AisListGroupItem></AisListGroup></AisCard></div><div><AisCardno-bodyheader="Card with flush list group and a card body"><AisListGroupflush><AisListGroupItem>List Group Item #1</AisListGroupItem><AisListGroupItem>List Group Item #2</AisListGroupItem><AisListGroupItem>List Group Item #3</AisListGroupItem><AisListGroupItem>List Group Item #4</AisListGroupItem></AisListGroup><AisCardBody>
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim
exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit
ipsum anim Lorem.
</AisCardBody></AisCard></div></div></template><scriptsetup>import{ AisListGroup }from'@ais-public/ais-components';import{ AisListGroupItem }from'@ais-public/ais-components';import{ AisCard }from'@ais-public/ais-components';import{ AisCardBody }from'@ais-public/ais-components';</script>
Bind to @click to handle the card's click event. Bind to @header-click event to handle the card header's click event.
Card Events
Click on the card header to trigger a header-click event.
Click anywhere on the card to trigger a click event.
<template><div><AisCardno-bodyheader="Card Events"header-class="font-medium"@click="handleClick"@header-click="handleHeaderClick"><AisListGroupflush><AisListGroupItem>Click on the card header to trigger a <code>header-click</code> event.</AisListGroupItem><AisListGroupItem>Click anywhere on the card to trigger a <code>click</code> event.</AisListGroupItem></AisListGroup></AisCard></div></template><scriptsetup>import{ AisCard }from'@ais-public/ais-components';import{ AisListGroup }from'@ais-public/ais-components';import{ AisListGroupItem }from'@ais-public/ais-components';consthandleClick=(e)=> console.log(`card.click: event=[${e}]`)consthandleHeaderClick=(e)=> console.log(`card-header.click: isOpen=[${e}]`)</script>