domestic-ui GitHub

Card

A self-contained item, such as an article teaser, on a raised surface.

Our choice: No standard exists: an <article> whose heading holds the one link, so the link name stays short.

Where cards are used Cards sit in a grid in the content area, each a raised box with a heading link and a short text.

Live example

Cards in a grid

<div class="grid" style="--grid-min: 16rem">
  <article data-card>
    <header>
      <h3>Starter plan</h3>
      <p>For one person trying things out.</p>
    </header>
    <p>Free forever, with every component and theme.</p>
    <footer>
      <a href="#grid-title" data-button="primary small">Choose Starter</a>
    </footer>
  </article>
  <article data-card="link">
    <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 160'%3E%3Crect width='320' height='160' fill='%233451d1'/%3E%3Ccircle cx='250' cy='40' r='60' fill='%238ea2ff'/%3E%3Crect x='24' y='96' width='140' height='40' rx='8' fill='%23f6f7f9'/%3E%3C/svg%3E" alt="" width="320" height="160">
    <header>
      <h3><a href="#grid-title">Theming guide</a></h3>
      <p>Override semantic tokens to make a theme.</p>
    </header>
    <p>No build step: set a few custom properties and every component follows.</p>
    <footer>
      <span data-badge="accent">Guide</span>
      <a href="#grid-title" data-button="secondary small">View tokens</a>
    </footer>
  </article>
  <article data-card="link">
    <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 160'%3E%3Crect width='320' height='160' fill='%2317773a'/%3E%3Cpath d='M0 160 L120 50 L200 120 L260 70 L320 120 V160Z' fill='%235fd38d'/%3E%3C/svg%3E" alt="" width="320" height="160">
    <h3><a href="#grid-title">Atoms</a></h3>
    <p>Buttons, switches, fields and badges.</p>
  </article>
</div>

Attributes

Attribute or valueWhereEffect
data-card<article> (or <section>, <li>)the card
data-card="link"the whole card follows the link in its heading

Children: an optional first <img> (or <picture>, <video>) as media, a heading, body content, and an optional <footer> for actions.

Wrap the heading and a one-line description in a <header> to set them close together, with the description muted, as shadcn/ui's card header does (https://ui.shadcn.com/docs/components/card).

Elevation

--dui-elevation-raised and --dui-elevation-raised-surface (level 1), whose 1px ring draws the edge. The border is transparent; forced colors mode, which drops box-shadow, paints it in canvastext.

Keyboard

KeyAction
Tabmoves to each card's heading link, then to its footer actions
Enterfollows the focused link

Accessibility

  • Every card has a heading. Use <article> when it stands on its own.
  • Images need alt, or alt="" when decorative.
  • data-card="link" stretches the heading's link over the card, so the link name is the heading (Inclusive Components). Footer actions stay focusable. Card text cannot be selected with the mouse.

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search