Debian Codegraph @

docs/user_guide/web-components.rst

raw
1 .. INSPIRED FROM sphinx-design documentation
2
3 ========================
4 Sphinx Design Components
5 ========================
6
7 On this page, you will find user interface components such as badges, buttons,
8 cards, and tabs.
9
10 The components on this page are **not provided by PyData Theme**.
11 They are provided by `Sphinx Design <https://sphinx-design.readthedocs.io/en/pydata-theme/index.html>`_ (a Sphinx extension).
12 This means that if you wish to use the components on this page, you must install Sphinx Design separately and add it to your `conf.py`.
13
14 .. seealso::
15
16 To add the Sphinx Design extension to your Sphinx project, refer to `Sphinx
17 Design - Getting Started
18 <https://sphinx-design.readthedocs.io/en/pydata-theme/get_started.html>`_.
19
20 Contributors to both projects have worked to ensure compatible styling so that
21 Sphinx Design components look and feel consistent with the PyData Theme.
22
23 This page shows you how the Sphinx Design components would look on your site if
24 you were to use them in combination with the PyData Theme. Sphinx Design also
25 provides a `PyData-themed version of the Sphinx Design site
26 <https://sphinx-design.readthedocs.io/en/pydata-theme/>`__; however, their site
27 use an older version of this theme.
28
29 Any customizations you make to the theme could affect how these components
30 appear on your site. So what you see on this page might not match exactly what
31 you see on your site even if your site uses this theme.
32
33 .. _badges-buttons:
34
35 Badges and button-links
36 =======================
37
38 Here are some of the available badges:
39
40 :bdg-primary:`primary`
41 :bdg-secondary:`secondary`
42 :bdg-success:`success`
43 :bdg-primary-line:`primary outline`
44 :bdg-secondary-line:`secondary outline`
45 :bdg-success-line:`success outline`
46
47 Here are some of the available button-style links, also using semantic colors:
48
49 .. grid:: auto
50
51 .. grid-item::
52
53 .. button-ref:: badges-buttons
54 :ref-type: ref
55 :color: info
56 :shadow:
57
58 Info
59
60 .. grid-item::
61
62 .. button-ref:: badges-buttons
63 :ref-type: ref
64 :color: success
65 :shadow:
66
67 Success
68
69 .. grid-item::
70
71 .. button-ref:: badges-buttons
72 :ref-type: ref
73 :color: warning
74 :shadow:
75
76 Warning
77
78 .. grid-item::
79
80 .. button-ref:: badges-buttons
81 :ref-type: ref
82 :color: danger
83 :shadow:
84
85 Danger
86
87 .. grid-item::
88
89 .. button-ref:: badges-buttons
90 :ref-type: ref
91 :color: muted
92 :shadow:
93
94 Muted
95
96 .. grid-item::
97
98 .. button-ref:: badges-buttons
99 :ref-type: ref
100 :color: light
101 :shadow:
102
103 Light
104
105 .. grid-item::
106
107 .. button-ref:: badges-buttons
108 :ref-type: ref
109 :color: dark
110 :shadow:
111
112 Dark
113
114 .. grid-item::
115
116 .. button-ref:: badges-buttons
117 :ref-type: ref
118 :color: secondary
119 :shadow:
120
121 Secondary
122
123 .. grid-item::
124
125 .. button-ref:: badges-buttons
126 :ref-type: ref
127 :color: primary
128 :shadow:
129
130 Primary
131
132 .. note::
133
134 `Sphinx Design buttons
135 <https://sphinx-design.readthedocs.io/en/latest/badges_buttons.html>`__ are
136 actually links, meaning they are rendered in HTML with ``<a>`` tags instead
137 of ``<button>``. Use them if you need a link to look like a button, but try
138 not to overuse them as they are not considered best practice for
139 accessibility. (For example, it upsets user interface expectations because
140 the space bar can be used on ``<button>``-tag buttons but not on ``<a>``-tag
141 links that look like buttons.)
142
143 If in your site's :ref:`custom CSS file <custom-css>` you override the :ref:`CSS
144 custom properties <css-variables>` ``--pst-color-*`` (where ``*`` is one of the
145 semantic color names, such as ``primary``, ``danger``), badges and buttons will
146 automatically use the custom color.
147
148 Cards
149 =====
150
151 .. grid::
152
153 .. grid-item-card:: Only heading
154
155 .. grid-item-card::
156
157 Only body.
158
159 But with multiple text paragraphs.
160
161 .. grid-item-card:: Heading and body
162
163 Content of the third card.
164
165 :bdg-primary:`Sample badge`
166
167 .. grid::
168
169 .. grid-item-card:: A card with a dropdown menu
170
171 .. dropdown:: :fa:`eye me-1` Click to expand dropdown
172
173 Hidden content
174
175 .. grid-item-card:: A clickable card
176 :link: https://sphinx-design.readthedocs.io/en/pydata-theme/cards.html#clickable-cards
177 :link-alt: Clickable cards - Sphinx Design docs
178
179 Don't forget to add the alternative text with ``link-alt``!
180
181 .. grid::
182
183 .. grid-item-card::
184
185 panel 1 header
186 ^^^^^^^^^^^^^^
187 panel 1 content
188 more content
189 ++++++++++++++
190 panel 1 footer
191
192 .. grid-item-card::
193
194 panel 2 header
195 ^^^^^^^^^^^^^^
196 panel 2 content
197 ++++++++++++++
198 panel 2 footer
199
200 Tabs
201 ====
202
203 .. tab-set::
204
205 .. tab-item:: c++
206
207 .. code-block:: c++
208
209 int main(const int argc, const char **argv) {
210 return 0;
211 }
212
213 .. tab-item:: python
214
215 .. code-block:: python
216
217 def main():
218 return
219
220 .. tab-item:: java
221
222 .. code-block:: java
223
224 class Main {
225 public static void main(String[] args) {
226 }
227 }
228
229 .. tab-item:: julia
230
231 .. code-block:: julia
232
233 function main()
234 end
235
236 .. tab-item:: fortran
237
238 .. code-block:: fortran
239
240 PROGRAM main
241 END PROGRAM main
242
243 Dropdowns
244 =========
245
246 Dropdowns look similar to admonitions, but they are clickable interactive elements that can be used to hide content.
247 See `the Sphinx Design Dropdown documentation <https://sphinx-design.readthedocs.io/en/latest/dropdowns.html>`__ for more information.
248
249 .. admonition:: An admonition for reference.
250
251 And some admonition content.
252
253 .. dropdown::
254
255 And with no title and some content!
256
257 .. dropdown:: With a title
258
259 And some content!
260
261 .. dropdown:: With a title and icon
262 :icon: unlock
263
264 And some content and an icon!
265
266 .. dropdown:: A primary color dropdown
267 :color: primary
268 :icon: unlock
269
270 And some content!
271
272 .. dropdown:: A secondary color dropdown
273 :color: secondary
274 :icon: unlock
275
276 And some content!
277
278 Copybuttons
279 ===========
280
281 `sphinx-copybutton <https://sphinx-copybutton.readthedocs.io/en/latest/>`__ adds a copy button to each of your code cells.
282 You can see it in action by hovering over the code cell below:
283
284 .. code-block:: python
285
286 print("A copybutton in the top-right!")
287
288 .. admonition:: nbsphinx
289
290 If your documentation site uses both nbsphinx and Sphinx-copybutton, you
291 will want to add the following line to your ``conf.py`` file to prevent the
292 copy button from appearing on top of notebook cell numbers:
293
294 .. code-block:: python
295 :caption: conf.py
296
297 copybutton_selector = ":not(.prompt) > div.highlight pre"
298
299 Toggle buttons
300 ==============
301
302 `sphinx-togglebutton <https://sphinx-togglebutton.readthedocs.io/en/latest/>`__ allows you to convert admonitions into toggle-able elements.
303
304 .. admonition:: Click me to toggle!
305 :class: dropdown
306
307 This will be hidden until a click!
308
309 .. toggle::
310
311 A standalone toggle button!