Debian Codegraph @

docs/content/en/shortcodes/details.md

raw
1 ---
2 title: Details shortcode
3 linkTitle: Details
4 description: Insert an HTML details element into your content using the details shortcode.
5 categories: []
6 keywords: []
7 ---
8
9 {{< new-in 0.140.0 />}}
10
11 > [!NOTE]
12 > To override Hugo's embedded `details` shortcode, copy the [source code][] to a file with the same name in the `layouts/_shortcodes` directory.
13
14 ## Example
15
16 With this Markdown:
17
18 ```md
19 {{</* details summary="See the details" */>}}
20 This is a **bold** word.
21 {{</* /details */>}}
22 ```
23
24 Hugo renders this HTML:
25
26 ```html
27 <details>
28 <summary>See the details</summary>
29 <p>This is a <strong>bold</strong> word.</p>
30 </details>
31 ```
32
33 Which looks like this in your browser:
34
35 {{< details summary="See the details" >}}
36 This is a **bold** word.
37 {{< /details >}}
38
39 ## Arguments
40
41 `summary`
42 : (`string`) The content of the child `summary` element rendered from Markdown to HTML. Default is `Details`.
43
44 `open`
45 : (`bool`) Whether to initially display the content of the `details` element. Default is `false`.
46
47 `class`
48 : (`string`) The `class` attribute of the `details` element.
49
50 `name`
51 : (`string`) The `name` attribute of the `details` element.
52
53 `title`
54 : (`string`) The `title` attribute of the `details` element.
55
56 ## Styling
57
58 Use CSS to style the `details` element, the `summary` element, and the content itself.
59
60 ```css
61 /* target the details element */
62 details { }
63
64 /* target the summary element */
65 details > summary { }
66
67 /* target the children of the summary element */
68 details > summary > * { }
69
70 /* target the content */
71 details > :not(summary) { }
72 ```
73
74 [source code]: <{{% eturl details %}}>