npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spectrum-web-components/card

v1.12.1

Published

An `<sp-card>` represents a rectangular card that contains a variety of text and image layouts. Cards are typically used to encapsulate units of a data set, such as a gallery of image/caption pairs.

Readme

Overview

An <sp-card> represents a rectangular card that contains a variety of text and image layouts. Cards are typically used to encapsulate units of a data set, such as a gallery of image/caption pairs.

Usage

See it on NPM! How big is this package in your project? Try it on Stackblitz

yarn add @spectrum-web-components/card

Import the side effectful registration of <sp-card> via:

import '@spectrum-web-components/card/sp-card.js';

When looking to leverage the Card base class as a type and/or for extension purposes, do so via:

import { Card } from '@spectrum-web-components/card';

Anatomy

Normal cards can contain a heading, a subheading, a cover photo, and a footer.

<sp-card heading="Card Heading">
  <img alt="" slot="cover-photo" src="https://picsum.photos/250/300" />
  <span slot="subheading">JPG photo</span>
  <div slot="footer">Footer</div>
</sp-card>

Heading

By default, the heading for an <sp-card> is applied via the heading attribute, which is restricted to string content only. For HTML content, use the heading slot instead.

<sp-card
  heading="Card Heading"
  subheading="JPG Photo"
  style="--spectrum-card-body-header-height: auto;"
>
  <img alt="" slot="cover-photo" src="https://picsum.photos/250/300" />
  <div slot="footer">Footer</div>
</sp-card>
<sp-card
  subheading="JPG Photo"
  style="--spectrum-card-body-header-height: auto;"
>
  <h1 slot="heading">Card Heading</h1>
  <img alt="" slot="cover-photo" src="https://picsum.photos/250/300" />
  <div slot="footer">Footer</div>
</sp-card>

Linking

An <sp-card> can be provided with an href attribute in order for it to act as one large anchor element. When leveraging the href attribute, the download, target and rel attributes customize the card's linking behavior. Use them as follows:

<sp-card
  heading="Card Title"
  subheading="JPG"
  href="https://opensource.adobe.com/spectrum-web-components"
  target="_blank"
>
  <img
    slot="cover-photo"
    src="https://picsum.photos/200/300"
    alt="Demo Image"
  />
</sp-card>

Cover Photo

Use slot="cover-photo" on an image to set it as the card's cover photo.

<sp-card heading="Card Heading" subheading="JPG Photo">
  <img
    slot="cover-photo"
    src="https://picsum.photos/200/300"
    alt="Demo Image"
  />
  <div slot="footer">Footer</div>
</sp-card>

Preview Image

Use slot="preview" on an image to set it as the card's preview image.

<sp-card heading="Card Title" subheading="JPG">
  <img slot="preview" src="https://picsum.photos/200/300" alt="Demo Image" />
  <div slot="footer">Footer</div>
</sp-card>

No Preview Image

Cards with no preview image can contain a heading, a subheading, and a footer.

<sp-card heading="Card Title" subheading="No Preview Image">
  <div slot="footer">Footer</div>
</sp-card>

Actions

Cards can be supplied an actions via a names slot.

<sp-card heading="Card Heading" subheading="JPG Photo">
  <img
    slot="cover-photo"
    src="https://picsum.photos/200/300"
    alt="Demo Image"
  />
  <div slot="footer">Footer</div>
  <sp-action-menu
    label="More Actions"
    slot="actions"
    placement="bottom-end"
    quiet
  >
    <sp-menu-item>Deselect</sp-menu-item>
    <sp-menu-item>Select Inverse</sp-menu-item>
    <sp-menu-item>Feather...</sp-menu-item>
    <sp-menu-item>Select and Mask...</sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>Save Selection</sp-menu-item>
    <sp-menu-item disabled>Make Work Path</sp-menu-item>
  </sp-action-menu>
</sp-card>

Options

Horizontal

Cards with a horizontal attribute can contain a heading, a subheading, a cover photo, and a description.

<sp-card horizontal heading="Card Heading" subheading="JPG Photo">
  <img alt="" slot="cover-photo" src="https://picsum.photos/200/250" />
  <div slot="description">10/15/18</div>
</sp-card>

Variant

There are multiple card variants to choose from in Spectrum. The variant attribute controls the main variant of the card.

Cards with variant="quiet" can contain a heading, a subheading, a cover photo, a description, and a footer. Quiet cards will also accept actions via a named slot.

<sp-card variant="quiet" heading="Card Heading" subheading="JPG Photo">
  <img alt="" slot="preview" src="https://picsum.photos/200/350" />
  <div slot="description">10/15/18</div>
  <sp-action-menu
    label="More Actions"
    slot="actions"
    placement="bottom-end"
    quiet
  >
    <sp-menu-item>Deselect</sp-menu-item>
    <sp-menu-item>Select Inverse</sp-menu-item>
    <sp-menu-item>Feather...</sp-menu-item>
    <sp-menu-item>Select and Mask...</sp-menu-item>
    <sp-menu-divider></sp-menu-divider>
    <sp-menu-item>Save Selection</sp-menu-item>
    <sp-menu-item disabled>Make Work Path</sp-menu-item>
  </sp-action-menu>
</sp-card>

Cards with variant="gallery" can contain a heading, a subheading, an image preview, a description, and a footer.

<sp-card variant="gallery" heading="Card Heading" subheading="JPG Photo">
  <img alt="" slot="preview" src="https://picsum.photos/532/192" />
  <div slot="description">10/15/18</div>
  <div slot="footer">Footer</div>
</sp-card>

Asset

When leveraging the asset attribute, a card can be declared as representing a file or a folder:

<sp-card heading="Card Heading" subheading="JPG Photo" asset="file">
  <div slot="heading">File Name</div>
  <div slot="description">10/15/18</div>
  <div slot="footer">Footer</div>
</sp-card>
<sp-card subheading="JPG Photo" asset="folder">
  <div slot="heading">Folder Name</div>
  <div slot="description">10/15/18</div>
  <div slot="footer">Footer</div>
</sp-card>

Toggles

When the toggles boolean attribute set to true, the card can be toggled between selected and unselected states. A checkbox will be rendered on hover, focus within, and when the card is selected.

<sp-card toggles variant="quiet" heading="Card Heading" subheading="JPG Photo">
  <img alt="" slot="preview" src="https://picsum.photos/200/350" />
  <div slot="description">10/15/18</div>
</sp-card>

Accessibility

Be concise

Heading text should be no more than 5-7 words. If the card has an href, the heading is used as a link and should ideally be no more than 3 words. For buttons, 1-2 words.

Use descriptive heading, link, and button text

Be descriptive. Set expectations on what someone will find and where they will go once they interact with a card. Avoid using the same text on more than one interactive element, unless both elements go to the same place.

Make the first word in a heading meaningful

Consider making the first word of links, buttons and headings something an assistive technology user might search for when headings and links are listed alphabetically.