Debian Codegraph @

docs/cards.md

raw
1 (sd-cards)=
2
3 # Cards
4
5 Cards contain content and actions about a single subject.
6 A card is a flexible and extensible content container,
7 it can be formatted with components including headers and footers, titles and images.
8
9 :::{card} Card Title
10
11 Card content
12 :::
13
14 See the [Material Design](https://material.io/components/cards) and [Bootstrap card](https://getbootstrap.com/docs/5.0/layout/grid/) descriptions for further details.
15
16 `````{dropdown-syntax}
17
18 ````{tab-set-code}
19 ```{literalinclude} ./snippets/myst/card-basic.txt
20 :language: markdown
21 ```
22 ```{literalinclude} ./snippets/rst/card-basic.txt
23 :language: rst
24 ```
25 ````
26 `````
27
28 All content before the first occurrence of three or more `^^^` is considered as a header,
29 and all content after the final occurrence of three or more `+++` is considered as a footer:
30
31 :::{card} Card Title
32 Header
33 ^^^
34 Card content
35 +++
36 Footer
37 :::
38
39 `````{dropdown-syntax}
40
41 ````{tab-set-code}
42 ```{literalinclude} ./snippets/myst/card-head-foot.txt
43 :language: markdown
44 ```
45 ```{literalinclude} ./snippets/rst/card-head-foot.txt
46 :language: rst
47 ```
48 ````
49 `````
50
51 When using cards in grids (see [`grid-item-card`](./grids.md)) footers can be aligned.
52
53 ::::{grid} 2
54 :::{grid-item-card} Card Title
55 Header
56 ^^^
57 Card content
58 +++
59 Footer
60 :::
61 :::{grid-item-card} Card Title
62 Header
63 ^^^
64 Longer
65
66 Card content
67 +++
68 Footer
69 :::
70 ::::
71
72 ## Card images
73
74 You can also add an image as the background of a card or at the top/bottom of the card, with the `img-background`, `img-top`, `img-bottom` options:
75
76 :::::{grid} 2 3 3 4
77
78 ::::{grid-item}
79
80 :::{card} Title
81 :img-background: images/particle_background.jpg
82 :class-card: sd-text-black
83 :img-alt: your desired alt text
84
85 Text
86 :::
87
88 ::::
89
90 ::::{grid-item-card} Title
91 :img-top: images/particle_background.jpg
92 :img-alt: your desired alt text
93
94 Header
95 ^^^
96 Content
97 +++
98 Footer
99 ::::
100
101 ::::{grid-item-card} Title
102 :img-bottom: images/particle_background.jpg
103 :img-alt: your desired alt text
104
105 Header
106 ^^^
107 Content
108 +++
109 Footer
110 ::::
111
112 :::::
113
114 `````{dropdown-syntax}
115
116 ````{tab-set-code}
117 ```{literalinclude} ./snippets/myst/card-images.txt
118 :language: markdown
119 ```
120 ```{literalinclude} ./snippets/rst/card-images.txt
121 :language: rst
122 ```
123 ````
124 `````
125
126 (cards-clickable)=
127
128 ## Clickable cards
129
130 Using the `link` and `link-type` options, you can turn an entire card into a clickable link.
131 Try hovering over then clicking on the cards below:
132
133 :::{card} Clickable Card (external)
134 :link: https://example.com
135 :link-alt: example.com
136
137 The entire card can be clicked to navigate to `https://example.com`.
138 :::
139
140 :::{card} Clickable Card (internal)
141 :link: cards-clickable
142 :link-type: ref
143
144 The entire card can be clicked to navigate to the `cards-clickable` reference target.
145 :::
146
147 `````{dropdown-syntax}
148
149 ````{tab-set-code}
150 ```{literalinclude} ./snippets/myst/card-link.txt
151 :language: markdown
152 ```
153 ```{literalinclude} ./snippets/rst/card-link.txt
154 :language: rst
155 ```
156 ````
157 `````
158
159 The **external link** created above is equivalent to using `<https://example.com>`
160 (<https://example.com>),
161 or if the `link-alt` option is provided, `[alt text](https://example.com)`
162 ([alt text](https://example.com)).
163
164 :::{tip}
165 Using URLs as link text makes it harder
166 for disabled people and for search engines to digest your web page,
167 so it's best to provide link text via the `link-alt` option.
168 :::
169
170 The **internal link** created above is equivalent to using `` {ref}`cards-clickable` ``
171 ({ref}`cards-clickable`),
172 or if the `link-alt` option is provided, `` {ref}`alt text <cards-clickable>` ``
173 ({ref}`alt text <cards-clickable>`).
174
175 :::{note}
176 You cannot add additional links to the clickable card, neither in the card
177 title nor in the card body. The entire card becomes a single link to the
178 destination you specify, which overrides any other links inside the card.
179 :::
180
181
182
183 ## Aligning cards
184
185 You can use the `text-align` option to align the text in a card,
186 and also `auto` margins to align the cards horizontally.
187
188 :::{card} Align Center
189 :width: 75%
190 :margin: 0 2 auto auto
191 :text-align: center
192
193 Content
194 :::
195
196 :::{card} Align Right
197 :width: 50%
198 :margin: 0 2 auto 0
199 :text-align: right
200
201 Content
202 :::
203
204 :::{card} Align Left
205 :width: 50%
206 :margin: 0 2 0 auto
207 :text-align: left
208
209 Content
210 :::
211
212 (cards:carousel)=
213
214 ## Card carousels
215
216 The `card-carousel` directive can be used to create a single row of fixed width, scrollable cards.
217 The argument should be a number between 1 and 12, to denote the number of cards to display.
218
219 When scrolling a carousel, the scroll will snap to the start of the nearest card:
220
221 ::::{card-carousel} 2
222
223 :::{card} card 1
224 content
225 :::
226 :::{card} card 2
227 Longer
228
229 content
230 :::
231 :::{card} card 3
232 :::
233 :::{card} card 4
234 :::
235 :::{card} card 5
236 :::
237 :::{card} card 6
238 :::
239 ::::
240
241 `````{dropdown-syntax}
242
243 ````{tab-set-code}
244 ```{literalinclude} ./snippets/myst/card-carousel.txt
245 :language: markdown
246 ```
247 ```{literalinclude} ./snippets/rst/card-carousel.txt
248 :language: rst
249 ```
250 ````
251 `````
252
253 (cards:options)=
254
255 ## `card` options
256
257 width
258 : The width that the card should take up (in %): auto, 25%, 50%, 75%, 100%.
259
260 margin
261 : Outer margin of grid.
262 One (all) or four (top bottom left right) values from: 0, 1, 2, 3, 4, 5, auto.
263
264 text-align
265 : Default horizontal text alignment: left, right, center or justify
266
267 img-background
268 : A URI (relative file path or URL) to an image to be placed below the content.
269
270 img-top
271 : A URI (relative file path or URL) to an image to be placed above the content.
272
273 img-bottom
274 : A URI (relative file path or URL) to an image to be placed below the content.
275
276 img-alt
277 : Alternative text for the image (that will be used by screen-readers).
278
279 link
280 : Turn the entire card into a clickable link to an external/internal target.
281
282 link-type
283 : Type of link: `url` (default), `ref`, `doc`, `any`.
284
285 link-alt
286 : Alternative text for the link (that will be used by screen-readers).
287
288 shadow
289 : The size of the shadow below the card: `none`, `sm` (default), `md`, `lg`.
290
291 class-card
292 : Additional CSS classes for the card container element.
293
294 class-header
295 : Additional CSS classes for the header element.
296
297 class-body
298 : Additional CSS classes for the body element.
299
300 class-title
301 : Additional CSS classes for the title element.
302
303 class-footer
304 : Additional CSS classes for the footer element.
305
306 class-img-top
307 : Additional CSS classes for the top image (if present).
308
309 class-img-bottom
310 : Additional CSS classes for the bottom image (if present).