Panelize
Quarto extension that formats code cells into a tabset panel, displaying static and interactive code cells side-by-side with code cell options.
Install / Use
/learn @coatless-quarto/PanelizeREADME
panelize: Tabset Code Cells in Quarto <img src="logo-panelize.png" align ="right" alt="" width ="150"/>
The quarto-panelize extension allows you to tabbify existing code cells to show their source or add interactivity.
Installation
To install the quarto-panelize extension, follow these steps:
-
Enter a Quarto project.
-
Open your terminal inside the Quarto project.
-
Run the following command:
quarto add coatless-quarto/panelize
If you wish to make your code interactive, please install the following Quarto extensions:
# For Python
quarto add coatless-quarto/pyodide
# For R
quarto add coatless/quarto-webr
These commands will download and install the extension as well as any dependencies under the _extensions subdirectory of your Quarto project. If you are using version control, ensure that you include this directory in your repository.
Usage
For each document, place the panelize filter in the document's header:
filters:
- panelize
Then, wrap existing R or Python code cells using a Div and specify the a panelize class.
Supported options include:
| Class | Description |
|---------------|-------------------------------------------------------------------------------------|
| .to-source | Convert a code cell to show rendered output and its source. |
| .to-pyodide | Convert code cell from static Python code to interactive Python code using Pyodide. |
| .to-webr | Convert code cell from static R code to interactive R code using webR. |
Display Source
For example, if we have a code cell with R that we want to show its options, then we use:
:::{.to-source}
```{r}
#| echo: fenced
#| eval: true
1 + 1
```
:::
This will generate output equivalent to:
:::{.panel-tabset}
### Results
```{r}
#| eval: true
1 + 1
```
### Source
```{{r}}
#| eval: true
1 + 1
```
:::
Interactivity
For creating a tabset that contains both rendered results and interactive option, modify the document header and place the desired extension filter after panelize, e.g.
filters:
- panelize
- pyodide
- webr
[!IMPORTANT]
Order matters! Please make sure to place the filters after
panelize. Otherwise, the interactivity filter will not detect the code cell!
Next, wrap the existing code cell using a Div with a class of either .to-pyodide or .to-webr.
For Python, that looks like:
:::{.to-pyodide}
```{python}
4 + 5
```
:::
For R, that looks like:
:::{.to-webr}
```{r}
1 + 1
```
:::
Acknowledgements
Thanks to @mcanouil and @cscheid who provided great insight into approaching this problem by re-orienting it in a way that is more managable. Please see the full discussion.
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.7kCommit, push, and open a PR
