Skip to main content Design tokens Components Style utilities
Skip to table of contents

    Card

    Cards can be used to group related subjects in a container.

    <pc-card class="card-overview">
      <img
          slot="image"
          src="https://placehold.co/300x200"
          alt="A placeholder image with grey background and dark grey text in resolution 300 by 200 pixels"
      />
    
      <strong slot="header">Lorem ipsum</strong>
    
      <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
          do eiusmod tempor incididunt ut labore et dolore magna
          aliqua.
      </p>
    
      <footer slot="footer">
          <pc-button appearance="primary" pill>
              <pc-icon
                  library="default"
                  icon-style="solid"
                  name="cart-shopping"
                  slot="prefix"
              ></pc-icon>
              Buy
          </pc-button>
          <pc-button appearance="text" pill>
              More info
              <span class="pc-visually-hidden">about this card</span>
          </pc-button>
      </footer>
    </pc-card>
    
    <style>
      .card-overview {
          max-width: 300px;
      }
    
      .card-overview footer {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          gap: var(--pc-spacing-xs);
      }
    </style>
    Code

    Demos

    Basic card

    Basic cards aren’t very exciting, but they can display any content you want them to.

    With header

    Headers can be used to display titles and more.

    Footers can be used to display actions, summaries or other relevant content.

    Images

    Cards accept an image slot. The image is displayed at the top of the card and stretches to fit.

    Slots

    NameDescription
    (default)The card’s main content.
    imageAn optional image to render at the start of the card.
    headerAn optional header for the card.
    footerAn optional footer for the card.
    imageAn optional image to render at the start of the card.

    Learn more about using slots.

    Custom properties

    NameDescriptionDefault
    --border-colorThe card’s border colour, including borders inside the card.-
    --border-radiusThe border radius of the card.-
    --border-widthThe stroke width of the card’s borders.-
    --paddingThe padding surrounding the card’s content.-

    Learn more about customising custom properties.

    Parts

    NameDescription
    baseThe component’s base wrapper.
    imageThe container that wraps the card’s image.
    headerThe container that wraps the card’s header.
    bodyThe container that wraps the card’s main content.
    footerThe container that wraps the card’s footer.

    Learn more about customising CSS parts.

    Importing

    If you’re using the autoloader or the standard loader, you can ignore this section. If you’re cherry picking, you can use any of the following snippets to import this component.

    ScriptImportBundler

    To import this component from the CDN with a script tag, copy this snippet and paste it in your HTML.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@0.5.1/dist/components/card/card.js"></script>

    To import this component from the CDN using a JavaScript import, copy this snippet and paste it in your JavaScript:

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@0.5.1/dist/components/card/card.js";

    To import this component with a bundler using a JavaScript import, copy this snippet and paste it in your JavaScript:

    import "placer-toolkit/dist/components/card/card.js";