This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can use a custom admonition title and apply the style of a "built-in"
admonition (e.g., `note`, `warning`, etc) with the `admonition::` directive:
::::{tab-set}
:::{tab-item} MyST
### Configure the CSS selector used to insert toggle buttons
````md
```{admonition} Here's my title
:class: dropdown, warning
By default, `sphinx-togglebutton` will use this selector:
My note
```
````
:::
:::{tab-item} reStructuredText
```rst
.. admonition:: Here's my title
:class: dropdown, warning
My note
.toggle, .admonition.dropdown
```
:::
::::
Creates:
However, you can customize this behavior with the `togglebutton_selector` configuration value.
To specify the selector to use, pass a valid CSS selector as a string:
:::{admonition} Here's my title
:class: dropdown, warning
:::{admonition} example
:class: tip
Configure `sphinx-togglebutton` to look for a `.toggle-this-element` class and an element with ID `#my-special-id` **instead of** `.toggle` and `.admonition.dropdown`.
To show the content by default, add a `toggle-shown` class as well.
:::{tab-set-code}
(dropdown-admonitions)=
## Collapse admonitions with the `dropdown` class
````markdown
```{note}
:class: dropdown, toggle-shown
`sphinx-togglebutton` treats admonitions as a special case if they are selected.
If a Sphinx admonition matches the toggle button selector, then its title will be displayed with a button to reveal its content.
This is my note.
:::{admonition} example
:class: tip
````md
```{admonition} This will be shown
:class: dropdown
And this will be hidden!
```
````
```rst
.. note::
:class: dropdown, toggle-shown
This is my note.
results in
```{admonition} This will be shown
:class: dropdown
And this will be hidden!
```
:::
This will generate the following block:
This works for any kind of Sphinx admoniton:
:::{note}
:class: dropdown, toggle-shown
:class: dropdown
A note!
:::
This is my note.
:::{warning}
:class: dropdown
A warning!
:::
(toggle-directive)=
## Toggle any content with the toggle directive
## Use the `{toggle}` directive to toggle blocks of content
To add toggle-able content, use the **toggle directive**. This directive
will wrap its content in a toggle-able container. You can call it like so:
Expand Down
Expand Up
@@ -169,12 +141,37 @@ It results in the following:
Here is my toggle-able content!
:::
## Control the togglebutton hover text
## Change the button hint text
You can control the "hint" text that is displayed next to togglebuttons when
their content is collapsed. To do so, use the following configuration variable
in your `conf.py` file:
You can control the "hint" text that is displayed next to togglebuttons.
To do so, use the following configuration variable in your `conf.py` file:
```python
togglebutton_hint = "My text"
togglebutton_hint = "Displayed when the toggle is closed."
togglebutton_hint_hide = "Displayed when the toggle is open."
```
## Change the toggle icon color
You can apply some extra styles to the toggle button to achieve the look you want.
This is particularly useful if the color of the toggle button does not contrast with the background of an admonition.
To style the toggle button, [add a custom CSS file to your documentation](https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html) and include a custom CSS selector like so:
```scss
// Turn the color red...
// ...with admonition toggle buttons
button.toggle-button {
color: red;
}
// ...with content block toggle buttons
.toggle-button summary {
color: red;
}
```
## Printing behavior with toggle buttons
When you print the screen while using `sphinx-togglebutton`, the toggle-able content will not show up.
To reveal it for printing, you must manually un-toggle the items and then print.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ENH: Enhance toggle button design and layout #32
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
ENH: Enhance toggle button design and layout #32
Filter by extension
Only manifest files
Deleted files Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.