On this page

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.

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.

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.

search-button-field

Shows a button that reads Search the docs, or the text set in search_bar_text, with the keys that open the search dialog beside it: Ctrl+K or ⌘K on any page, and / when the reader is not typing in a field. It is named in navbar_persistent by default, and a site may name it in any other component list instead.

The dialog comes with the button: it is written once at the end of every page, whichever list names the button. A site that sets disable_search to True draws neither the button nor the dialog, and the shortcuts do nothing. The options search_bar_text and search_as_you_type set its words and whether results appear as the reader types.

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’s components/ 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, and tooltip_class adds a placement class to it, such as tooltip-bottom, written out in full. Each entry of data becomes a data- attribute on the button, so {"daisy-search-close": ""} writes data-daisy-search-close; a page script finds the button by it. With an href, the macro draws a link to that address in place of the button, with the same label, tooltip and attributes. Used with call, 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. rel is 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 with call. 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 %}
    

    tag and panel_tag name the outer element and the panel. trigger_class and panel_class add classes to the button and the panel, label is the button’s accessible name, and attrs and trigger_attrs are dicts of attributes for the outer element and the button. Every value is escaped. The outer element carries the class daisy-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.