CSS variables¶
It is possible to customize your Sphinx site with Nefertiti using CSS variables. By providing a custom.css with a :root declaration and the following CSS variables, you can further customize your site.
Custom stylesheet.css file¶
Sphinx can include additional CSS files. There are several settings you can use in your conf.py:
In both cases the file paths given are relative to the directory referred by the html_static_path #3 setting.
The following content in conf.py would look for a custom.css file in your _static directory, next to your document source files:
html_static_path = ["_static"]
html_style = "custom.css"
In the following custom.css example, the font-size applied to the body is 1.1rem instead of the default 1rem. Also the font-weight applied to headers is 700 instead of the default of 300. Additionally the --nftt-doc-headers-color is customized for the light and dark color schemes:
:root {
--nftt-body-font-size: 1.1rem;
--nftt-doc-headers-font-weight: 700;
--light-red: #ff7777;
--dark-red: #6f003c;
}
:root:not(.light):not(.dark) {
color-scheme: light dark;
--nftt-doc-headers-color: var(--dark-red);
@media (prefers-color-scheme: light) {
--nftt-doc-headers-color: var(--dark-red);
}
@media (prefers-color-scheme: dark) {
--nftt-doc-headers-color: var(--light-red);
}
}
:root:is(.light) {
--nftt-doc-headers-color: var(--dark-red);
}
:root:is(.dark) {
--nftt-doc-headers-color: var(--light-red);
}
CSS Font Variables¶
Font families and font size are indicated directly in the conf.py file, as explained in fonts.
Variable Name |
Description |
|---|---|
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
Color for elements |
|
Color for elements |
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
It defaults to |
CSS Blockquotes¶
Variable Name |
Description |
|---|---|
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
It defaults to |
CSS Tables¶
Variable Name |
Description |
|---|---|
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
It defaults to |
|
It has to be defined for |
|
It defaults to |
|
It defaults to |