1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: Card
summary: >-
Flat surface, no border, radius-lg. A step lighter than the page marks the
edge. Elevation is opt-in, reserved for the one focused card in a view — a
dialog, the primary capture card.
---
A `<div>`/`<article>` is too generic to style bare, so Card keeps one
sanctioned class. `[data-elevated]` is for the single most-elevated element on
screen — never a whole grid of cards at once.
## Flat vs. elevated
<figure class="example">
<figcaption>Flat and elevated</figcaption>
<div data-surface="sunken">
<div class="card" style="width: 14rem; padding: var(--gl-space-s);">Flat — the default.</div>
<div class="card" data-elevated style="width: 14rem; padding: var(--gl-space-s);">Elevated — one per view.</div>
</div>
<details><summary>Markup</summary>
<pre><code><div class="card" style="width: 14rem; padding: var(--gl-space-s);">Flat — the default.</div>
<div class="card" data-elevated style="width: 14rem; padding: var(--gl-space-s);">Elevated — one per view.</div></code></pre>
</details>
</figure>
## As a content tile
Used standalone (not as a row-list), `.card` is fine on its own — `.card-body`
and `.card-footer` are two more sanctioned classes, for the one shape inside
it that has no element of its own to hang a selector on.
<figure class="example">
<figcaption>Content tile</figcaption>
<div data-surface="sunken">
<article class="card" style="max-width: 18rem;">
<div class="card-body">
<p class="type-label" style="margin:0;">Recommended</p>
<h3>Rename the caution color</h3>
<p>Three people have called it "yellow" in review this month.</p>
</div>
<div class="card-footer">
<button data-variant="primary" data-size="sm">Approve</button>
<button data-variant="ghost" data-size="sm">Dismiss</button>
</div>
</article>
</div>
<details><summary>Markup</summary>
<pre><code><article class="card" style="max-width: 18rem;">
<div class="card-body">
<p class="type-label" style="margin:0;">Recommended</p>
<h3>Rename the caution color</h3>
<p>Three people have called it "yellow" in review this month.</p>
</div>
<div class="card-footer">
<button data-variant="primary" data-size="sm">Approve</button>
<button data-variant="ghost" data-size="sm">Dismiss</button>
</div>
</article></code></pre>
</details>
</figure>
## As a list — with CardRow
Card's most common job in this system is holding a list of
[CardRow](<%= relative_url('/components/card-row/') %>)s: entry lists, task
lists, settings rows. In that shape Card is a real `<ul class="card">` and
CardRow is a bare `<li>` — the divider between rows comes from the `.card >
li` descendant selector, no second class needed.
<figure class="example">
<figcaption>Card of rows</figcaption>
<div data-surface="sunken">
<ul class="card" style="max-width: 22rem;">
<li>Dishwasher manual</li>
<li>Sofa receipt</li>
<li>Passport scan</li>
</ul>
</div>
<details><summary>Markup</summary>
<pre><code><ul class="card" style="max-width: 22rem;">
<li>Dishwasher manual</li>
<li>Sofa receipt</li>
<li>Passport scan</li>
</ul></code></pre>
</details>
</figure>
## API
<table>
<thead><tr><th scope="col">Element / attribute</th><th scope="col">Values</th><th scope="col">Notes</th></tr></thead>
<tbody>
<tr><td><code>.card</code></td><td></td><td>Required base, on a <code><div></code>/<code><article></code> for a standalone tile or a <code><ul></code> for a list of rows.</td></tr>
<tr><td><code>data-elevated</code></td><td>boolean</td><td>Applies <code>--gl-shadow-float</code>. One per view.</td></tr>
<tr><td><code>> li</code></td><td></td><td>A CardRow, when Card is a <code><ul></code>. See <a href="<%= relative_url('/components/card-row/') %>">CardRow</a>.</td></tr>
</tbody>
</table>