Components¶
A component is a template that a component list names. The theme provides these. Each one draws nothing when what it shows is switched off, so a list can name it without checking.
copyright¶
Shows the copyright line from the copyright setting, as a link when the site has a page named
copyright. It is drawn when html_show_copyright is true, which is Sphinx’s default, and the
site has a copyright setting.
sphinx-version¶
Shows “Built with Sphinx” and the version of Sphinx that built the site, linked to Sphinx’s
website. It is drawn when html_show_sphinx is true, which is Sphinx’s default.
theme-version¶
Shows the theme’s name, linked to its repository, and the installed version of the theme. It is always drawn.
last-updated¶
Shows the date the page was last updated. It is drawn when html_last_updated_fmt is set to a
date format, such as "%d %B %Y". Sphinx leaves it unset by default.
edit-this-page¶
Shows a link labelled Edit this page, drawn as a ghost button with a pencil icon, that leads to
the page’s source file on the host’s editing page. The address comes from the
options source_repository, source_branch and source_directory. It draws
nothing when the page has no edit address. It is not in a component list by default, and is
meant for secondary_sidebar_items. Link the sources shows
the steps.
sourcelink¶
Shows a link labelled Show source, drawn as a ghost button with a file icon, that leads to
Sphinx’s copy of the page’s source under _sources. It draws only when both
html_show_sourcelink and html_copy_source are on, and a page with no source draws nothing.
It is not in a component list by default, and is meant for secondary_sidebar_items.
Link the sources shows the steps.
theme-switcher¶
Shows a button that opens a menu of the three modes: match the system, light and dark. When the
option theme_picker names themes, the menu lists them below the modes, each with
a swatch of its colours. The button shows the reader’s current choice. The theme puts it in
navbar_end, and on a narrow window it moves into the drawer with the rest of that list.
The site’s themes and its starting mode apply with or without it. A site that leaves the component
out of every list draws no menu, and every page still follows light_theme, dark_theme and
default_mode, and the reader’s system when the mode is "auto".
version-switcher¶
Shows a button labelled with the version being built, which opens a menu of every version in the
file named by the switcher option. The reader’s own version is marked, and so is
the preferred one. The theme puts it in navbar_end, and on a narrow window it moves into the
drawer with the rest of that list.
It draws nothing unless switcher gives a json_url. The check_switcher and
show_version_warning_banner options set whether the build checks the file and whether a banner
warns on a version that is not the preferred one.
page-toc¶
Shows the headings of the page, nested as they are in the page, under the label On this page.
The heading being read is marked as the reader scrolls, and the last heading is marked at the
foot of the page. The option show_toc_level sets how deep the list is open.
It draws nothing on a page with no headings below its title, nor on the search page or an
index. It is named in secondary_sidebar_items by default, and when it is named there, a
closed On this page disclosure with the same headings appears above the page on narrow windows.
Your own components¶
A site adds a component by putting a template in a directory listed in templates_path, and
naming it in a component list. A template named status.html is named status or
status.html. Arrange the page shows the steps.
A template has the page’s full context, as every Sphinx template does, and the theme’s own
values under daisy.
A name that matches no template draws nothing and raises no warning.
Macros¶
components/macros.html holds four macros a component may import:
{%- from 'components/macros.html' import components, icon_button with context %}
components(names)draws each name in a list, looking in the theme’scomponents/directory first and then in the site’s templates.icon_button(label, icon, tooltip="", data={}, href="", tooltip_class="")draws a ghost button holding the named icon. The label is the button’s accessible name. When a tooltip is given, it shows on hover, andtooltip_classadds a placement class to it, such astooltip-bottom, written out in full. Each entry ofdatabecomes adata-attribute on the button, so{"daisy-search-close": ""}writesdata-daisy-search-close; a page script finds the button by it. With anhref, the macro draws a link to that address in place of the button, with the same label, tooltip and attributes. Used withcall, the caller’s markup fills the button in place of the named icon.source_link(href, icon, label, rel="")draws a ghost link, as wide as its content, holding the named icon and the label, for a list of page tools.relis added to the link when given.navbar_dropdown(tag="div", panel_tag="div", trigger_class="", panel_class="", label="", attrs={}, trigger_attrs={})draws one menu in the navbar and is used withcall. It draws the outer element, the button that opens the menu and the panel, and the caller fills the button and the panel:{%- call(part) navbar_dropdown(panel_tag="ul", panel_class="menu w-56") %} {%- if part == "trigger" %}Menu{% else %}<li><a href="#">An entry</a></li>{% endif %} {%- endcall %}
tagandpanel_tagname the outer element and the panel.trigger_classandpanel_classadd classes to the button and the panel,labelis the button’s accessible name, andattrsandtrigger_attrsare dicts of attributes for the outer element and the button. Every value is escaped. The outer element carries the classdaisy-dropdown, which the theme’s script uses to open the menu from the keyboard and to close it with Escape, wherever the menu sits on the page.