卡片(Cards)

卡片是一种灵活且可扩展的内容容器。 它包括页眉和页脚选项,各种内容,上下文背景颜色以及强大的显示选项。

介绍

卡片的标记和样式尽可能少,但是仍然可以提供大量的控制和自定义功能。 内置flexbox,它们易于对准并与其他组件混合良好组件。

<b-card> 没有固定的开始宽度,因此它们自然会填充其父元素的整个宽度。 您可以通过样式或标准的Bootstrap v4尺寸设置类轻松地对其进行自定义。

通过 tag 属性指定,将默认的 div 根标签更改为任何其他HTML元素。

Image

Card Title

Some quick example text to build on the card title and make up the bulk of the card's content.

Go somewhere
<div>
  <b-card
    title="Card Title"
    img-src="https://picsum.photos/600/300/?image=25"
    img-alt="Image"
    img-top
    tag="article"
    style="max-width: 20rem;"
    class="mb-2"
  >
    <b-card-text>
      Some quick example text to build on the card title and make up the bulk of the card's content.
    </b-card-text>

    <b-button href="#" variant="primary">Go somewhere</b-button>
  </b-card>
</div>

内容类型

卡片支持各种各样的内容,包括图像、文本、列表组、链接等等。下面是 <b-card> 支持的示例

卡片主体

<b-card> 的构建块是 <b-card-body> 部分,它提供了卡片内的填充部分。

默认情况下, <b-card> 内容自动放置在 <b-card-body> 节中:

这是 <b-card-body> 组件的默认 <b-card> >块中的一些内容。 请注意,卡片的边框和此灰色 <div>之间的填充。
<div>
  <b-card class="text-center">
    <div class="bg-secondary text-light">
      This is some content within the default <samp>&lt;b-card-body&gt;</samp> block of the
      <samp>&lt;b-card&gt;</samp> component. Notice the padding between the card's border and this
      gray <samp>&lt;div&gt;</samp>.
    </div>
  </b-card>
</div>

通过在 <b-card> 上设置 no-body 属性禁用自动 <b-card-body> 部分(和相关的填充)。

这是一些没有默认 <b-card-body> 部分的内容。 请注意,卡片的边框和此灰色 <div>之间没有填充。
<div>
  <b-card no-body class="text-center">
    <div class="bg-secondary text-light">
      This is some content without the default <samp>&lt;b-card-body&gt;</samp> section. Notice the
      lack of padding between the card's border and this gray <samp>&lt;div&gt;</samp>.
    </div>
  </b-card>
</div>

请注意,no-body 启用后,titlesub-title 道具的内容将不会渲染。

使用 <b-card-body> 子组件将您自己的卡片主体放置在 no-body<b-card> 组件中。

卡片标题 是通过 title 属性添加的,子标题 是通过 sub-title 属性添加的。标题使用子组件渲染,<b-card-title> 而子标题使用子组件渲染 <b-card-sub-title>

通过子组件 <b-card-text>,可以将段落文本添加到卡片中。最后一个 <b-card-text> 将会被自动删除(通过CSS)。<b-card-text> 中的文本也可以使用标准的HTML标记样式化。

通过将 .card-link 类添加到 <a> 标签(或 <b-link>组件)中,可以添加链接并将它们放在一起。

Card title

Card subtitle

Some quick example text to build on the card title and make up the bulk of the card's content.

A second paragraph of text in the card.

Card link Another link
<div>
  <b-card title="Card title" sub-title="Card subtitle">
    <b-card-text>
      Some quick example text to build on the <em>card title</em> and make up the bulk of the card's
      content.
    </b-card-text>

    <b-card-text>A second paragraph of text in the card.</b-card-text>

    <a href="#" class="card-link">Card link</a>
    <b-link href="#" class="card-link">Another link</b-link>
  </b-card>
</div>

图片

<b-card> 属性 img-src 将图像放置在卡的顶部,并使用 img-alt 属性指定要在图像 alt 属性中放置的字符串。由 img-src 道具指定的图像将响应并在更改卡的宽度时调整其宽度。

或者,您可以 <b-card> 使用子组件手动将图像放置在内部 <b-card-img> 。有关用法,请参见下面的厨房水槽示例。

Top and Bottom

Card image

Some quick example text to build on the card and make up the bulk of the card's content.

Some quick example text to build on the card and make up the bulk of the card's content.

Card image

Left and Right (or Start and End)

Card image

Some quick example text to build on the card and make up the bulk of the card's content.

Card image

Some quick example text to build on the card and make up the bulk of the card's content.

<div>
  <div>
    <h4>Top and Bottom</h4>
    <b-card-group deck>
      <b-card img-src="https://placekitten.com/1000/300" img-alt="Card image" img-top>
        <b-card-text>
          Some quick example text to build on the card and make up the bulk of the card's content.
        </b-card-text>
      </b-card>

      <b-card img-src="https://placekitten.com/1000/300" img-alt="Card image" img-bottom>
        <b-card-text>
          Some quick example text to build on the card and make up the bulk of the card's content.
        </b-card-text>
      </b-card>
    </b-card-group>
  </div>
  <div class="mt-4">
    <h4>Left and Right (or Start and End)</h4>
    <b-card img-src="https://placekitten.com/300/300" img-alt="Card image" img-left class="mb-3">
      <b-card-text>
        Some quick example text to build on the card and make up the bulk of the card's content.
      </b-card-text>
    </b-card>

    <b-card img-src="https://placekitten.com/300/300" img-alt="Card image" img-right>
      <b-card-text>
        Some quick example text to build on the card and make up the bulk of the card's content.
      </b-card-text>
    </b-card>
  </div>
</div>

注意: 对于左边和右边的图像,您可能需要对 .card-img-left.card-img-right类应用额外的样式,因为如果您的内容比图像高,图像将在高度上“拉伸”。注意:当图像左对齐或右对齐时,不支持页眉和页脚。您可能会发现,在创建响应式 水平卡片布局 时,水平卡片布局示例更加灵活。

叠加图像

通过设置布尔属性值(叠加) overlay,将图像置于卡片的背景中:

Card Image

Image Overlay

Subtitle

Some quick example text to build on the card and make up the bulk of the card's content.

<div>
  <b-card
    overlay
    img-src="https://picsum.photos/900/250/?image=3"
    img-alt="Card Image"
    text-variant="white"
    title="Image Overlay"
    sub-title="Subtitle"
  >
    <b-card-text>
      Some quick example text to build on the card and make up the bulk of the card's content.
    </b-card-text>
  </b-card>
</div>

懒加载图片

使用 <b-card-img-lazy> 子组件在图像滚动到视图中时延迟加载图像。 <b-card-img-lazy> 支持与 <b-card-img> 相同的属性以及 <b-img-lazy> 组件的许多属性。

通过页眉/页脚属性或命名的插槽在卡中添加可选的 header/footer 。 您可以通过设置 header-tagfooter-tag 属性来控制使用的包装器元素标签( 默认均为 div

<div>
  <b-card-group deck>
    <b-card
      header="featured"
      header-tag="header"
      footer="Card Footer"
      footer-tag="footer"
      title="Title"
    >
      <b-card-text>Header and footers using props.</b-card-text>
      <b-button href="#" variant="primary">Go somewhere</b-button>
    </b-card>

    <b-card title="Title" header-tag="header" footer-tag="footer">
      <template v-slot:header>
        <h6 class="mb-0">Header Slot</h6>
      </template>
      <b-card-text>Header and footers using slots.</b-card-text>
      <b-button href="#" variant="primary">Go somewhere</b-button>
      <template v-slot:footer>
        <em>Footer Slot</em>
      </template>
    </b-card>
  </b-card-group>
</div>

厨房水槽示例

混合和匹配多种内容类型来创建您需要的卡片,或者将所有内容都放入其中。下面显示的是图像样式、块、文本样式和列表组—所有这些都包装在固定宽度的卡片中。

Image

Hello World

Card Title

Card Sub Title

Some quick example text to build on the card title and make up the bulk of the card's content.

Cras justo odio
Dapibus ac facilisis in
Vestibulum at eros
Image
<div>
  <b-card
    no-body
    style="max-width: 20rem;"
    img-src="https://placekitten.com/380/200"
    img-alt="Image"
    img-top
  >
    <template v-slot:header>
      <h4 class="mb-0">Hello World</h4>
    </template>

    <b-card-body>
      <b-card-title>Card Title</b-card-title>
      <b-card-sub-title class="mb-2">Card Sub Title</b-card-sub-title>
      <b-card-text>
        Some quick example text to build on the card title and make up the bulk of the card's
        content.
      </b-card-text>
    </b-card-body>

    <b-list-group flush>
      <b-list-group-item>Cras justo odio</b-list-group-item>

      <b-list-group-item>Dapibus ac facilisis in</b-list-group-item>
      <b-list-group-item>Vestibulum at eros</b-list-group-item>
    </b-list-group>

    <b-card-body>
      <a href="#" class="card-link">Card link</a>
      <a href="#" class="card-link">Another link</a>
    </b-card-body>

    <b-card-footer>This is a footer</b-card-footer>

    <b-card-img src="https://placekitten.com/480/210" alt="Image" bottom></b-card-img>
  </b-card>
</div>

水平卡片布局

使用网格(grid)组件、实用程序类和单个卡片子组件的组合,可以使卡片以便于移动和响应的方式水平放置。

在下面的示例中,我们使用 <b-row> 上的 no-gutters 属性删除行网格装订线,并使用 <b-col> 上的 md 属性将卡片水平放置在 md 断点处。rounded-0 类将除去 <b-card-img> 的圆角,而 <b-card> 上的 overflow-hidden 将根据卡片的 border-radius 适当地裁剪图像的角。根据您的卡片内容,可能需要进一步调整。

Horizontal Card

This is a wider card with supporting text as a natural lead-in to additional content. This content is a little bit longer.

<div>
  <b-card no-body class="overflow-hidden" style="max-width: 540px;">
    <b-row no-gutters>
      <b-col md="6">
        <b-card-img src="https://picsum.photos/400/400/?image=20" class="rounded-0"></b-card-img>
      </b-col>
      <b-col md="6">
        <b-card-body title="Horizontal Card">
          <b-card-text>
            This is a wider card with supporting text as a natural lead-in to additional content.
            This content is a little bit longer.
          </b-card-text>
        </b-card-body>
      </b-col>
    </b-row>
  </b-card>
</div>

文本变量

默认情况下,卡片使用深色文字并采用浅色背景。 您可以通过 text-variant属性切换文本以及卡的子组件的颜色来反转颜色。 然后,指定深色背景变体。

Card Title

With supporting text below as a natural lead-in to additional content.

Go somewhere
<b-card bg-variant="dark" text-variant="white" title="Card Title">
  <b-card-text>
    With supporting text below as a natural lead-in to additional content.
  </b-card-text>
  <b-button href="#" variant="primary">Go somewhere</b-button>
</b-card>

背景和边框变量

卡片包含自己的变量样式,可通过 bg-variantborder-variant 属性快速更改背景颜色以及卡片的颜色。较暗的实体变量我需要设置 text-variant 属性来调整文本颜色。

Solid

Primary

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Secondary

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Success

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Info

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Warning

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Danger

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Light

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Dark

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Default

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

<div>
  <div>
    <b-card-group deck>
      <b-card bg-variant="primary" text-variant="white" header="Primary" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card bg-variant="secondary" text-variant="white" header="Secondary" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card bg-variant="success" text-variant="white" header="Success" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
  <div class="mt-3">
    <b-card-group deck>
      <b-card bg-variant="info" text-variant="white" header="Info" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card bg-variant="warning" text-variant="white" header="Warning" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card bg-variant="danger" text-variant="white" header="Danger" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
  <div class="mt-3">
    <b-card-group deck>
      <b-card bg-variant="light" header="Light" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card bg-variant="dark" header="Dark" text-variant="white" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card header="Default" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
</div>

Bordered

Primary

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Secondary

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Success

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Info

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Warning

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Danger

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Light

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Dark

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

<div>
  <div>
    <b-card-group deck>
      <b-card
        border-variant="primary"
        header="Primary"
        header-bg-variant="primary"
        header-text-variant="white"
        align="center"
      >
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card
        border-variant="secondary"
        header="Secondary"
        header-border-variant="secondary"
        align="center"
      >
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card border-variant="success" header="Success" align="center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
  <div class="mt-3">
    <b-card-group deck>
      <b-card border-variant="info" header="Info" align="center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card
        border-variant="warning"
        header="Warning"
        header-bg-variant="transparent"
        align="center"
      >
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card
        border-variant="danger"
        header="Danger"
        header-border-variant="danger"
        header-text-variant="danger"
        align="center"
      >
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
  <div class="mt-3">
    <b-card-group deck class="mb-3">
      <b-card border-variant="light" header="Light" class="text-center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>

      <b-card border-variant="dark" header="Dark" align="center">
        <b-card-text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b-card-text>
      </b-card>
    </b-card-group>
  </div>
</div>

变量到类的映射

BootstrapVue <b-card> 变量直接映射到 Bootstrap v4 卡片类,通过预先挂起的 bg- (对于 solid) 或 border- (对于 bordered) 映射到上述变量名。

您还可以通过 header-bg-variantheader-border-variantheader-text-variantfooter-bg-variantfooter-border-variant,和 footer-text-variant 属性将 solid 和 border 变量应用于卡片的页眉和页脚和和页脚变量

<div>
  <b-card
    header="Card Header"
    header-text-variant="white"
    header-tag="header"
    header-bg-variant="dark"
    footer="Card Footer"
    footer-tag="footer"
    footer-bg-variant="success"
    footer-border-variant="dark"
    title="Title"
    style="max-width: 20rem;"
  >
    <b-card-text>Header and footers variants.</b-card-text>
  </b-card>
</div>

传输含义来辅助技术

使用颜色添加含义仅提供视觉指示,而不会传达给辅助技术的用户(例如屏幕阅读器)。 确保用颜色表示的信息从内容本身来看是显而易见的(例如,可见文本),或者通过其他方式包括在其中,例如用 .sr-only 类隐藏的其他文本。

<b-nav> 轻松集成到卡片页眉中。

使用(页眉) header 插槽

Card Title

With supporting text below as a natural lead-in to additional content.

<div>
  <b-card title="Card Title" body-class="text-center" header-tag="nav">
    <template v-slot:header>
      <b-nav card-header tabs>
        <b-nav-item active>Active</b-nav-item>
        <b-nav-item>Inactive</b-nav-item>
        <b-nav-item disabled>Disabled</b-nav-item>
      </b-nav>
    </template>

    <b-card-text>
      With supporting text below as a natural lead-in to additional content.
    </b-card-text>

    <b-button variant="primary">Go somewhere</b-button>
  </b-card>
</div>

使用 <b-card-header> 子组件:

Card Title

With supporting text below as a natural lead-in to additional content.

<div>
  <b-card no-body>
    <b-card-header header-tag="nav">
      <b-nav card-header tabs>
        <b-nav-item active>Active</b-nav-item>
        <b-nav-item>Inactive</b-nav-item>
        <b-nav-item disabled>Disabled</b-nav-item>
      </b-nav>
    </b-card-header>

    <b-card-body class="text-center">
      <b-card-title>Card Title</b-card-title>

      <b-card-text>
        With supporting text below as a natural lead-in to additional content.
      </b-card-text>

      <b-button variant="primary">Go somewhere</b-button>
    </b-card-body>
  </b-card>
</div>

有关在卡片页眉中使用 <b-nav> 的更多信息,请参阅 导航文档

Card groups

In addition to styling the content within cards, BootstrapVue includes a <b-card-group> component for laying out series of cards. For the time being, these layout options are not yet responsive.

Default card group

Use card groups to render cards as a single, attached element with equal width and height columns. Card groups use display: flex; to achieve their uniform sizing.

When using card groups with footers, their content will automatically line up.

Image

Title

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Image

Title

This card has supporting text below as a natural lead-in to additional content.

Image

Title

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.

<div>
  <b-card-group>
    <b-card title="Title" img-src="https://placekitten.com/g/300/450" img-alt="Image" img-top>
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This content is a little bit longer.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>

    <b-card title="Title" img-src="https://placekitten.com/g/300/450" img-alt="Image" img-top>
      <b-card-text>
        This card has supporting text below as a natural lead-in to additional content.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>

    <b-card title="Title" img-src="https://placekitten.com/g/300/450" img-alt="Image" img-top>
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This card has even longer content than the first to show that equal height action.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>
  </b-card-group>
</div>

Card deck groups

Need a set of equal width and height cards that aren't attached to one another? Use card decks by setting the deck prop. And just like with regular card groups, card footers in decks will automatically line up.

Image

Title

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Image

Title

This card has supporting text below as a natural lead-in to additional content.

Image

Title

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.

<div>
  <b-card-group deck>
    <b-card title="Title" img-src="https://picsum.photos/300/300/?image=41" img-alt="Image" img-top>
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This content is a little bit longer.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>

    <b-card title="Title" img-src="https://picsum.photos/300/300/?image=41" img-alt="Image" img-top>
      <b-card-text>
        This card has supporting text below as a natural lead-in to additional content.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>

    <b-card title="Title" img-src="https://picsum.photos/300/300/?image=41" img-alt="Image" img-top>
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This card has even longer content than the first to show that equal height action.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Last updated 3 mins ago</small>
      </template>
    </b-card>
  </b-card-group>
</div>

Card column groups

Cards can be organized into Masonry-like columns with by wrapping them in a <b-card-group> with the prop columns set. Cards are built with CSS column properties instead of flexbox for easier alignment. Cards are ordered from top to bottom and left to right.

Heads up! Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to display: inline-block as column-break-inside: avoid isn't a bulletproof solution yet.

Image

Card title that wraps to a new line

This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

Quote

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Someone famous in Source Title
Image

Title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Someone famous in Source Title

Title

This card has supporting text below as a natural lead-in to additional content.

Last updated 3 mins ago

Image
Image

This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first.

<div>
  <b-card-group columns>
    <b-card
      title="Card title that wraps to a new line"
      img-src="https://placekitten.com/g/400/450"
      img-alt="Image"
      img-top
    >
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This content is a little bit longer.
      </b-card-text>
    </b-card>

    <b-card header="Quote">
      <blockquote class="blockquote mb-0">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
        <footer class="blockquote-footer">
          Someone famous in <cite title="Source Title">Source Title</cite>
        </footer>
      </blockquote>
    </b-card>

    <b-card title="Title" img-src="https://placekitten.com/500/350" img-alt="Image" img-top>
      <b-card-text>
        This card has supporting text below as a natural lead-in to additional content.
      </b-card-text>
      <b-card-text class="small text-muted">Last updated 3 mins ago</b-card-text>
    </b-card>

    <b-card bg-variant="primary" text-variant="white">
      <blockquote class="card-blockquote">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
        <footer>
          <small>Someone famous in <cite title="Source Title">Source Title</cite></small>
        </footer>
      </blockquote>
    </b-card>

    <b-card>
      <b-card-title>Title</b-card-title>
      <b-card-text>
        This card has supporting text below as a natural lead-in to additional content.
      </b-card-text>
      <b-card-text class="small text-muted">Last updated 3 mins ago</b-card-text>
    </b-card>

    <b-card img-src="https://picsum.photos/400/400/?image=41" img-alt="Image" overlay></b-card>

    <b-card img-src="https://picsum.photos/400/200/?image=41" img-alt="Image" img-top>
      <b-card-text>
        This is a wider card with supporting text below as a natural lead-in to additional content.
        This card has even longer content than the first.
      </b-card-text>
      <template v-slot:footer>
        <small class="text-muted">Footer Text</small>
      </template>
    </b-card>
  </b-card-group>
</div>

Component reference

Properties

Property (Click to sort Ascending) Type Default Description
body-tag String 'div' Specify the HTML tag to render instead of the default tag for the body
body-bg-variant String Applies one of the Bootstrap theme color variants to the body background
body-border-variant String Applies one of the Bootstrap theme color variants to the body border
body-text-variant String Applies one of the Bootstrap theme color variants to the body text
body-class String or Object or Array CSS class (or classes) to apply to the body
title String Text content to place in the title
title-tag String 'h4' Specify the HTML tag to render instead of the default tag for the title
sub-title String Text content to place in the sub title
sub-title-tag String 'h6' Specify the HTML tag to render instead of the default tag for the sub title
sub-title-text-variant String 'muted' Applies one of the Bootstrap theme color variants to the sub title text
overlay Boolean false When set, will overlay the card body on top of the image (if the card has an image)
header-tag String 'div' Specify the HTML tag to render instead of the default tag for the header
header-bg-variant String Applies one of the Bootstrap theme color variants to the header background
header-border-variant String Applies one of the Bootstrap theme color variants to the header border
header-text-variant String Applies one of the Bootstrap theme color variants to the header text
header String Text content to place in the header
header-html Use with caution String HTML string content to place in the header. Use with caution
header-class String or Object or Array CSS class (or classes) to apply to the header
img-src String URL for the optional image
img-alt String Value to set the image attribute 'alt'
img-top Boolean false Set if the image should appear at the top of the card
img-bottom Boolean false Set if the image should appear at the bottom of the card
img-start Boolean false Set if the image should appear at the start (left) of the card
img-left Boolean false Set if the image should appear at the start (left) of the card. Synonym for the 'left' prop
img-end Boolean false Set if the image should appear at the end (right) of the card
img-right Boolean false Set if the image should appear at the end (right) of the card. Synonym for the 'right' prop
img-height Number or String The value to set on the image's 'height' attribute
img-width Number or String The value to set on the image's 'width' attribute
tag String 'div' Specify the HTML tag to render instead of the default tag
bg-variant String Applies one of the Bootstrap theme color variants to the background
border-variant String Applies one of the Bootstrap theme color variants to the border
text-variant String Applies one of the Bootstrap theme color variants to the text
align String Text alignment for the card's content: 'left', 'center' or 'right'
no-body Boolean false Disable rendering of the default inner card-body element

Caution: Props that support HTML strings (*-html) can be vulnerable to Cross Site Scripting (XSS) attacks when passed raw user supplied values. You must properly sanitize the user input first!

Slots

Slot Name Description
header For custom rendering of header content

<b-card-header>

Functional Component

Properties

Property Type Default Description
header-tag String 'div' Specify the HTML tag to render instead of the default tag for the header
header-bg-variant String Applies one of the Bootstrap theme color variants to the header background
header-border-variant String Applies one of the Bootstrap theme color variants to the header border
header-text-variant String Applies one of the Bootstrap theme color variants to the header text
header String Text content to place in the header
header-html Use with caution String HTML string content to place in the header. Use with caution
header-class String or Object or Array CSS class (or classes) to apply to the header

Caution: Props that support HTML strings (*-html) can be vulnerable to Cross Site Scripting (XSS) attacks when passed raw user supplied values. You must properly sanitize the user input first!

Functional Component
Property Type Default Description

Caution: Props that support HTML strings (*-html) can be vulnerable to Cross Site Scripting (XSS) attacks when passed raw user supplied values. You must properly sanitize the user input first!

Properties

Property (Click to sort Ascending) Type Default Description
body-tag String 'div' Specify the HTML tag to render instead of the default tag for the body
body-bg-variant String Applies one of the Bootstrap theme color variants to the body background
body-border-variant String Applies one of the Bootstrap theme color variants to the body border
body-text-variant String Applies one of the Bootstrap theme color variants to the body text
body-class String or Object or Array CSS class (or classes) to apply to the body
title String Text content to place in the title
title-tag String 'h4' Specify the HTML tag to render instead of the default tag for the title
sub-title String Text content to place in the sub title
sub-title-tag String 'h6' Specify the HTML tag to render instead of the default tag for the sub title
sub-title-text-variant String 'muted' Applies one of the Bootstrap theme color variants to the sub title text
overlay Boolean false When set, will overlay the card body on top of the image (if the card has an image)

<b-card-title>

Functional Component

Properties

Property Type Default Description
title String Text content to place in the title
title-tag String 'h4' Specify the HTML tag to render instead of the default tag for the title

<b-card-sub-title>

Functional Component

Properties

Property Type Default Description
sub-title String Text content to place in the sub title
sub-title-tag String 'h6' Specify the HTML tag to render instead of the default tag for the sub title
sub-title-text-variant String 'muted' Applies one of the Bootstrap theme color variants to the sub title text

Properties

Property (Click to sort Ascending) Type Default Description
src Required String URL to set for the 'src' attribute
alt String Value to set for the 'alt' attribute
top Boolean false Set if the image will be placed at the top of the card
bottom Boolean false Set if the image will be placed at the bottom of the card
start Boolean false Set if the image will be placed at the start (left) of the card
left Boolean false Set if the image will be placed at the start (left) of the card. Synonym for the 'left' prop
end Boolean false Set if the image will be placed at the end (right) of the card
right Boolean false Set if the image will be placed at the end (right) of the card. Synonym for the 'right' prop
height Number or String The value to set on the image's 'height' attribute
width Number or String The value to set on the image's 'width' attribute

<b-card-img-lazy>

Functional Component

Properties

Property (Click to sort Ascending) Type Default Description
src Required String URL to set for the 'src' attribute
srcset String or Array
sizes String or Array
alt String Value to set for the 'alt' attribute
width Number or String The value to set on the image's 'width' attribute
height Number or String The value to set on the image's 'height' attribute
blank-src String URL of placeholder image. If not set, an SVG placeholder placeholder will be used
blank-color String 'transparent' CSS color of the blank SVG placeholder image. Has no effect if 'blank-src' is set
blank-width Number or String Value of the 'width' attribute for the placeholder image
blank-height Number or String Value of the 'height' attribute for the placeholder image
show Boolean false If set to true, will force show the image specified via the 'src' prop
offset Number or String 360 Number of pixels away from the viewport edge before the lazy image is loaded
top Boolean false Set if the image will be placed at the top of the card
bottom Boolean false Set if the image will be placed at the bottom of the card
start Boolean false Set if the image will be placed at the start (left) of the card
left Boolean false Set if the image will be placed at the start (left) of the card. Synonym for the 'left' prop
end Boolean false Set if the image will be placed at the end (right) of the card
right Boolean false Set if the image will be placed at the end (right) of the card. Synonym for the 'right' prop

Properties

Property Type Default Description
text-tag String 'p' Specify the HTML tag to render instead of the default tag for the text content

<b-card-group>

Functional Component

Properties

Property Type Default Description
tag String 'div' Specify the HTML tag to render instead of the default tag
deck Boolean false When set renders the card group with gutters between cards
columns Boolean false When set, renders the card group in a masonry-like columnar style

Importing individual components

You can import individual components into your project via the following named exports:

Component Named Export Import Path
<b-card> BCard bootstrap-vue
<b-card-header> BCardHeader bootstrap-vue
<b-card-footer> BCardFooter bootstrap-vue
<b-card-body> BCardBody bootstrap-vue
<b-card-title> BCardTitle bootstrap-vue
<b-card-sub-title> BCardSubTitle bootstrap-vue
<b-card-img> BCardImg bootstrap-vue
<b-card-img-lazy> BCardImgLazy bootstrap-vue
<b-card-text> BCardText bootstrap-vue
<b-card-group> BCardGroup bootstrap-vue

Example:

import { BCard } from 'bootstrap-vue'
Vue.component('b-card', BCard)

Importing as a Vue.js plugin

This plugin includes all of the above listed individual components. Plugins also include any component aliases.

Named Export Import Path
CardPlugin bootstrap-vue

Example:

import { CardPlugin } from 'bootstrap-vue'
Vue.use(CardPlugin)