Frequently Asked Questions
General Information
What is the toggle extension for Quarto?
The toggle
Extension is a Quarto extension that allows you to add toggle buttons to your code cells. These buttons let readers show or hide the output of code blocks, making your documents more interactive and less cluttered.
Does toggle work with all Quarto formats?
This extension works with HTML-based output formats like:
- HTML documents
- Websites
- Books (HTML format)
- Revealjs presentations
It does not affect PDF, Word, or other non-HTML output formats as these formats don’t support the JavaScript functionality needed for toggling.
How is this different from Quarto’s built-in code folding?
Quarto’s built-in code-fold
option toggles visibility of the code while always showing the output. This extension does the opposite - it toggles visibility of the output while always showing the code.
You can use both features together:
---
title: "My Document"
format:
html:
code-fold: true
toggle:
output-toggle: true
filters:
- toggle
---
This gives readers maximum control over what they see.
Installation
How do I install the toggle Extension?
See the home page for details.
Is the toggle extension compatible with all Quarto versions?
The toggle
extension requires Quarto v1.7.0 or later.
Usage
Do I need to modify my existing code cells?
If you’ve enabled toggle at the document level, no changes are needed to your existing code cells. If you want to control toggle behavior for specific cells, you’ll need to add cell-level attributes.
How do I toggle output visibility for a specific cell?
Add the toggle: true
attribute to the cell:
```{python}
#| toggle: true
print("Hello, world!")
```
How do I disable toggle for a specific cell when it’s enabled at the document level?
Use the toggle: false
attribute:
```{python}
#| toggle: false
print("This output always shows")
```
What happens if a code cell doesn’t produce any output?
If a code cell doesn’t produce any output, the toggle button won’t appear even if toggle: true
is set for that cell.
What’s the difference between individual and synchronized control?
- Individual (
output-sync: false
): Each toggle button controls only its specific output - Synchronized (
output-sync: true
): Any toggle button controls ALL outputs in the cell
How do I sync output toggles in multioutput scenarios by default?
At the document level, set output-sync: true
in the YAML header:
toggle:
output-toggle: true
output-sync: true
Or at the cell level:
```{python}
#| toggle: true
#| output-sync: true
print("Hello, world!") # Same button to toggle both outputs
print("Goodbye, world!") # Same button to toggle both outputs
```
Support
How can I get help?
For additional support, bug reports, or feature requests, please visit the extension’s GitHub repository. For general Quarto help, please visit the Quarto community forum or the Quarto documentation.