You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/use.md
+35-24Lines changed: 35 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,34 +235,35 @@ encountered in a line.
235
235
236
236
To use a different image for your copy buttons, do the following:
237
237
238
-
1. Place the image inthe `_static/` folder of your site.
239
-
2. Set the `copybutton_image_path` variable in your `conf.py` to be the
240
-
path to your image file, **relative to**`_static/`.
238
+
1. Find the `<svg>` code forthe image that you'd like to use.
239
+
For example, find an SVG from [Font Awesome](https://fontawesome.com/), [Tabler](https://tablericons.com/), or [Octicons](https://primer.style/octicons/).
240
+
2. Set the `copybutton_image_svg` variable in your `conf.py` to the SVG that you'd like to use.
241
241
242
242
For example, if you wanted to use a **clipboard icon** instead of the default copy button icon, do the following:
243
243
244
244
1. Copy the `Clipboard Icon SVG` from [the Tabular icons pack](https://tablericons.com/).
When you re-build your documentation, you should see this new icon in your copy buttons.
@@ -288,27 +289,37 @@ added to them.
288
289
## Modify the copy button's CSS
289
290
290
291
You can style the CSS of the copy button however you'd like by writing your own CSS with your Sphinx build.
291
-
To do so, add a CSS rule that uses the `.copybtn` selector and the CSS that you'd like to apply.
292
-
293
-
For example, to make the copy button visible by default (not just when a code cell is hovered), do the following:
292
+
To do so, first create a custom CSS file and add it to your Sphinx build:
294
293
295
294
1. Create a `custom.css` file in the `_static/` folder of your documentation.
296
-
297
-
2. Add the following rule to it:
298
-
299
-
```css
300
-
button.copybtn {
301
-
opacity: 1;
302
-
}
303
-
```
304
-
305
-
3. Add the CSS file to Sphinx by ensuring that the following configuration exists in your `conf.py` file (see [the Sphinx documentation for more details](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files)):
295
+
2. Add the CSS file to Sphinx by ensuring that the following configuration exists in your `conf.py` file (see [the Sphinx documentation for more details](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files)):
306
296
307
297
```python
308
298
html_static_path = ["_static"]
309
299
html_css_files = ["custom.css"]
310
300
```
311
301
302
+
Next you can add CSS rules that use the `.copybtn` selector to modify the behavior of the button.
303
+
304
+
:::{admonition} example: button visibility
305
+
:class: tip
306
+
To make the copy button visible by default (not just when a code cell is hovered):
307
+
308
+
```css
309
+
button.copybtn {
310
+
opacity: 1;
311
+
}
312
+
```
313
+
:::
314
+
315
+
:::{admonition} example: style the color of the button
316
+
```css
317
+
button.copybtn {
318
+
color: red;
319
+
}
320
+
```
321
+
:::
322
+
312
323
See the [Sphinx documentation on custom CSS for more information](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path).
0 commit comments