| 1 |
(sd-dropdowns)= |
| 2 |
|
| 3 |
# Dropdowns |
| 4 |
|
| 5 |
Dropdowns can be used to toggle, usually *non-essential*, content and show it only when a user clicks on the header panel. |
| 6 |
|
| 7 |
The dropdown can have a title, as the directive argument, and the `open` option can be used to initialise the dropdown in the open state. |
| 8 |
|
| 9 |
:::{dropdown} |
| 10 |
Dropdown content |
| 11 |
::: |
| 12 |
|
| 13 |
:::{dropdown} Dropdown title |
| 14 |
Dropdown content |
| 15 |
::: |
| 16 |
|
| 17 |
:::{dropdown} Open dropdown |
| 18 |
:open: |
| 19 |
|
| 20 |
Dropdown content |
| 21 |
::: |
| 22 |
|
| 23 |
`````{dropdown-syntax} |
| 24 |
|
| 25 |
````{tab-set-code} |
| 26 |
```{literalinclude} ./snippets/myst/dropdown-basic.txt |
| 27 |
:language: markdown |
| 28 |
``` |
| 29 |
```{literalinclude} ./snippets/rst/dropdown-basic.txt |
| 30 |
:language: rst |
| 31 |
``` |
| 32 |
```` |
| 33 |
````` |
| 34 |
|
| 35 |
## Opening animations |
| 36 |
|
| 37 |
Use `:animate: fade-in` or `:animate: fade-in-slide-down` options to animate the reveal of the hidden content. |
| 38 |
|
| 39 |
:::{dropdown} Dropdown `fade-in` |
| 40 |
:animate: fade-in |
| 41 |
|
| 42 |
{{ loremipsum }} |
| 43 |
::: |
| 44 |
|
| 45 |
:::{dropdown} Dropdown `fade-in-slide-down` |
| 46 |
:animate: fade-in-slide-down |
| 47 |
|
| 48 |
{{ loremipsum }} |
| 49 |
::: |
| 50 |
|
| 51 |
## More examples |
| 52 |
|
| 53 |
:::{dropdown} Dropdown with icon |
| 54 |
:icon: quote |
| 55 |
|
| 56 |
Dropdown content |
| 57 |
::: |
| 58 |
|
| 59 |
:::{dropdown} Dropdown with icon and very long title, *lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, nunc nec fermentum ultricies, nunc sapien ultricies nunc, nec ultricies sapien sapien nec sapien* |
| 60 |
:icon: quote |
| 61 |
|
| 62 |
Dropdown content |
| 63 |
::: |
| 64 |
|
| 65 |
:::{dropdown} Using option `:chevron: down-up` |
| 66 |
:chevron: down-up |
| 67 |
|
| 68 |
Dropdown content |
| 69 |
::: |
| 70 |
|
| 71 |
## Dropdowns in other components |
| 72 |
|
| 73 |
Dropdowns can be nested inside other components, such as inside parent dropdowns or within [grid items](./grids.md). |
| 74 |
|
| 75 |
::::{admonition} Here is an admonition with a dropdown |
| 76 |
|
| 77 |
Admonition content |
| 78 |
|
| 79 |
:::{dropdown} Dropdown inside admonition |
| 80 |
:icon: quote |
| 81 |
|
| 82 |
{{ loremipsum }} |
| 83 |
::: |
| 84 |
:::: |
| 85 |
|
| 86 |
::::{dropdown} Parent dropdown title |
| 87 |
:open: |
| 88 |
|
| 89 |
:::{dropdown} Child dropdown title |
| 90 |
:color: warning |
| 91 |
:icon: alert |
| 92 |
|
| 93 |
Dropdown content |
| 94 |
::: |
| 95 |
:::: |
| 96 |
|
| 97 |
:::::{grid} 1 1 2 2 |
| 98 |
:gutter: 1 |
| 99 |
|
| 100 |
::::{grid-item} |
| 101 |
:::{dropdown} Dropdown Column 1 |
| 102 |
Dropdown content |
| 103 |
::: |
| 104 |
:::: |
| 105 |
|
| 106 |
::::{grid-item} |
| 107 |
:::{dropdown} Dropdown Column 2 |
| 108 |
Dropdown content |
| 109 |
::: |
| 110 |
:::: |
| 111 |
|
| 112 |
::::: |
| 113 |
|
| 114 |
## `dropdown` options |
| 115 |
|
| 116 |
open |
| 117 |
: Open the dropdown by default. |
| 118 |
|
| 119 |
color |
| 120 |
: Set the color of the dropdown header (background and font). |
| 121 |
One of the semantic color names: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`, `muted`. |
| 122 |
|
| 123 |
icon |
| 124 |
: Set an [octicon icon](icons) to prefix the dropdown header. |
| 125 |
|
| 126 |
chevron |
| 127 |
: The open-close direction of the chevron. |
| 128 |
One of: `right-down`, `down-up`. |
| 129 |
|
| 130 |
animate |
| 131 |
: Animate the dropdown opening (`fade-in` or `fade-in-slide-down`). |
| 132 |
|
| 133 |
margin |
| 134 |
: Outer margin of grid. |
| 135 |
One (all) or four (top bottom left right) values from: 0, 1, 2, 3, 4, 5, auto. |
| 136 |
|
| 137 |
name |
| 138 |
: Set a reference-able name for the dropdown container. |
| 139 |
|
| 140 |
class-container |
| 141 |
: Additional CSS classes for the container element. |
| 142 |
|
| 143 |
class-title |
| 144 |
: Additional CSS classes for the title element. |
| 145 |
|
| 146 |
class-body |
| 147 |
: Additional CSS classes for the body element. |