Data-driven Style and Typography for JupyterLab powered by JSS.
We're trying some things out here, and invite you test it out, but make no guarantees that it is good or even works. What we mean by that is covered in the shouty text at the bottom of the LICENSE.
If something is broken, become a contributor and raise an issue, but we cannot guarantee any kind of response time. Similarly, PRs will be reviewed on a time-permitting basis.
- Python >=3.8
- a Jupyter client
- JupyterLab >=3,<5
- for specific JupyterLab compatibility, see the changelog.
- Jupyter Notebook >=7,<8
- JupyterLab >=3,<5
pip install jupyterlab-fonts
# or
conda install -c conda-forge jupyterlab-fonts
We're sorry to see you go!
pip uninstall jupyterlab-fonts
# or
conda uninstall jupyterlab-fonts
To change your default fonts, from the main menu, select Settings ▶ Fonts ▶ Code ▶ Font (or Size or Line Height) and the value you'd like.
Some features of Content, i.e. your rendered Markdown and HTML, are also available, and more will hopefully be added over time.
You can view all available font configurations by selecting Settings ▶ Fonts ▶ Global Fonts.... These values will be stored in your JupyterLab settings.
When viewing an .ipynb
, change just the fonts for that file by clicking
in the Notebook toolbar (right now, next to cell type). The font, style
changes, and its license information will be stored in the Notebook metadata.
This can rapidly increase the size of your notebook file, and can make it harder to use in collaboration. We're looking into some alterate approaches.
In JupyterLab, the Fonts section of Advanced JSON Settings can control
things entirely unrelated to fonts. There's no guarantee that highly-customized styles
will work nicely with the Font Editor, or with downstream applications of
jupyterlab-fonts
metadata.
Here's an example of changing how a Notebook file looks when in Presentation Mode.
{
"styles": {
":root": {
"--jp-code-font-family": "'Fira Code Regular', 'Source Code Pro', monospace",
"--jp-code-font-size": "19px"
},
".jp-mod-presentationMode .jp-Notebook": {
"& .CodeMirror, & .cm-editor": {
"fontSize": "32px"
},
"& .jp-InputPrompt, & .jp-OutputPrompt": {
"display": "none"
}
}
}
}
Similarly, the JupyterLab Property Inspector enables these customizations in a
specific .ipynb
file, at both the document and cell level: these are dynamically
generated, and scoped to the document/cell id
.
The above example shows how different versions of JupyterLab (or Notebook) may use different DOM classes for the same logical content, such as:
Element | JupyterLab <4 | JupyterLab 4 |
---|---|---|
a code editor | .CodeMirror |
.cm-editor |
All JSON-compatible features of the jss-preset-default
plugins are
enabled with the default settings, with some specific notes below. For portability,
dynamic JS-based features are not supported.
The the &
(ampersand) allows for nesting selectors, as standardized by
the W3C CSS Nesting Module and implemented in many
browsers.
All settings-derived styles will be wrapped in a @global
selector.
overrides.json
allows for simple, declarative configuration of JupyterLab core and
third-party extensions, even after the lab server has been started.
{
"@deathbeds/jupyterlab-fonts:fonts": {
"styles": {
":root": {
"--jp-code-font-family": "'Fira Code Regular', 'Source Code Pro', monospace",
"--jp-code-font-size": "19px"
}
}
}
}
In binder, one might deploy this with a postBuild
script:
#!/usr/bin/env bash
set -eux
mkdir -p "${NB_PYTHON_PREFIX}/share/jupyter/lab/settings"
cp overrides.json "${NB_PYTHON_PREFIX}/share/jupyter/lab/settings"
Similarly, this is a well-known file to JupyterLite, making it straightforward to do light customization without needing to build and distribute a full theme plugin.