print("Always visible - no toggle button")
Always visible - no toggle button
This page demonstrates how to globally enable toggle functionality for all code cells, rather than enabling it on a per cell configuration. This approach allows you to skip individual cell configurations unless you want to override the global behavior.
To enable toggle for all cells, add this to your document’s YAML header:
---
title: "Your Document Title"
format: html
toggle:
output-toggle: true # Automatically add toggle to all cells
output-hidden: false # Show outputs by default
filters: [toggle]
---
With this set, every code cell that produces an output gets a toggle button automatically and outputs are visible by default. Readers can hide them if they choose.
This means:
toggle: true
to individual cells as it will apply to all.Hover over code blocks to see toggle buttons. "⌄"
= visible, "›"
= hidden.
print("Hello, world!")
Hello, world!
print("This has a toggle button.")
This has a toggle button.
= [1, 2, 3, 4, 5]
numbers print(f"Sum: {sum(numbers)}")
Sum: 15
print(f"Average: {sum(numbers)/len(numbers)}")
Average: 3.0
import matplotlib.pyplot as plt
1, 2, 3], [1, 4, 9], 'o-')
plt.plot(["Simple Plot")
plt.title( plt.show()
<- c(10, 20, 30, 40, 50)
data cat("Mean:", mean(data), "\n")
Mean: 30
cat("Max:", max(data), "\n")
Max: 50
barplot(c(23, 45, 32), names.arg = c("A", "B", "C"))
No toggle button will be added, output is always visible.
print("Always visible - no toggle button")
Always visible - no toggle button
echo "Current date:"
date
Current date:
Thu May 29 08:42:08 UTC 2025