Card

A bordered surface with header, title, description, content and footer parts.

Install

If this is the first component in the project, set up once. This writes ermine.json and copies the theme stylesheet. The installation guide covers Vue, Nuxt and Astro.

npx ermineui init
pnpm dlx ermineui init
yarn dlx ermineui init
bunx ermineui init

Then add the component:

npx ermineui add card
pnpm dlx ermineui add card
yarn dlx ermineui add card
bunx ermineui add card

That copies 7 files into src/components/ui/card/. Files you already have are kept.

Use

import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
<script setup lang="ts">
import { Card } from '@/components/ui/card'
</script>

<template>
  <Card />
</template>

In Nuxt, with the auto-import setting, the tags work in templates without the import. In Astro, use it inside a Vue island. The props are documented in the source below, on each one.

What gets copied

FileWhere it goes
Card.vuesrc/components/ui/card/Card.vue
CardContent.vuesrc/components/ui/card/CardContent.vue
CardDescription.vuesrc/components/ui/card/CardDescription.vue
CardFooter.vuesrc/components/ui/card/CardFooter.vue
CardHeader.vuesrc/components/ui/card/CardHeader.vue
CardTitle.vuesrc/components/ui/card/CardTitle.vue
index.tssrc/components/ui/card/index.ts

The folders are the suggested ones. ermine.json says where yours are.

Source

This is exactly what the command copies. To install by hand, create each file below and the helpers listed above.

Card.vue 52 lines
<template>
  <div class="er-card"><slot /></div>
</template>

<style>
@layer components {
  .er-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 0;
    border: 1px solid var(--er-border);
    border-radius: var(--er-radius-xl);
    background: var(--er-card);
    color: var(--er-card-foreground);
    box-shadow: var(--er-shadow-sm);
  }

  .er-card-header {
    display: grid;
    gap: 0.375rem;
    padding: 0 1.5rem;
  }

  .er-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: var(--er-weight-semibold);
    line-height: 1.25;
  }

  .er-card-description {
    margin: 0;
    color: var(--er-muted-foreground);
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .er-card-content {
    padding: 0 1.5rem;
  }

  .er-card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
  }
}
</style>
CardContent.vue 4 lines
<template>
  <div class="er-card-content"><slot /></div>
</template>
CardDescription.vue 4 lines
<template>
  <p class="er-card-description"><slot /></p>
</template>
CardFooter.vue 4 lines
<template>
  <div class="er-card-footer"><slot /></div>
</template>
CardHeader.vue 4 lines
<template>
  <div class="er-card-header"><slot /></div>
</template>
CardTitle.vue 4 lines
<template>
  <h3 class="er-card-title"><slot /></h3>
</template>
index.ts 8 lines
/** Card — a bordered surface with header, title, description, content and footer parts. */
export { default as Card } from './Card.vue'
export { default as CardContent } from './CardContent.vue'
export { default as CardDescription } from './CardDescription.vue'
export { default as CardFooter } from './CardFooter.vue'
export { default as CardHeader } from './CardHeader.vue'
export { default as CardTitle } from './CardTitle.vue'