{% set hasSidebar = true %} {% set hasOutline = true %} {# {% set forceTheme = page.fileSlug %} #} {% extends '../_includes/base.njk' %} {% block head %} {% endblock %} {% block header %}

Remix this theme Customize this theme by changing its colors and/or remixing it with design elements from other themes!

{% for theme in collections.theme | sort %} {% set currentTheme = theme.fileSlug == page.fileSlug %}
{% include "svgs/theme-color.njk" %}
{{ theme.data.title }} {% if theme.data.isPro %}PRO{% endif %} {% if currentTheme %}This theme{% endif %}
{% endfor %}
{% set defaultPalette = palette %} {% for palette in collections.palette | sort %} {% set currentPalette = palette.fileSlug == defaultPalette %}
{% include "svgs/" + (palette.data.icon or "thumbnail-placeholder") + ".njk" ignore missing %}
{{ palette.data.title }} {% if palette.data.isPro %}PRO{% endif %} {% if currentPalette %}Theme default{% endif %}
{% endfor %} {% set palette = defaultPalette %}
{% for hue in hues %} {% set currentBrand = hue == brand %} {{ hue | capitalize }} {% if currentBrand %}Theme default{% endif %} {% endfor %}
{% for theme in collections.theme | sort %} {% set currentTheme = theme.fileSlug == page.fileSlug %}
{% include "svgs/theme-typography.njk" %}
{{ theme.data.title }} {% if theme.data.isPro %}PRO{% endif %} {% if currentTheme %}This theme{% endif %}
{% endfor %}

Color

{% set paletteURL = '/docs/palettes/' + palette + '/' %}
{% set themePage = page %} {% set page = paletteURL | getCollectionItemFromUrl %} {% set pageSubtitle = "Default color palette" %} {% include 'page-card.njk' %} {% set page = themePage %}
{{ brand | capitalize }}
{% endblock %} {% block afterContent %}

How to use this theme

{% markdown %} You can import this theme from the Web Awesome CDN. {% set stylesheet = 'styles/themes/' + page.fileSlug + '.css' %} {% include 'import-stylesheet-code.md.njk' %} ## Dark mode To activate the dark color scheme of the theme on any element and its contents, apply the class `wa-dark` to it. This means you can use different color schemes throughout the page. Here, we use the default theme with a dark sidebar: ```html ``` You can apply the class to the `` element on your page to activate the dark color scheme for the entire page. ```html ``` ### Detecting Color Scheme Preference Web Awesome's themes have both light and dark styles built in. However, Web Awesome doesn't try to auto-detect the user's light/dark mode preference. This should be done at the application level. As a best practice, to provide a dark theme in your app, you should: - Check for [`prefers-color-scheme`](https://stackoverflow.com/a/57795495/567486) and use its value by default - Allow the user to override the setting in your app - Remember the user's preference and restore it on subsequent logins Web Awesome avoids using the `prefers-color-scheme` media query because not all apps support dark mode, and it would break things for the ones that don't. Assuming the user's preference is in a variable called `colorScheme` (values: `auto`, `light`, `dark`), you can use the following JS snippet to apply the `wa-dark` class to the `` element accordingly: ```js const systemDark = window.matchMedia('(prefers-color-scheme: dark)'); const applyDark = function (event = systemDark) { const isDark = colorScheme === 'auto' ? event.matches : colorScheme === 'dark'; document.documentElement.classList.toggle('wa-dark', isDark); }; systemDark.addEventListener('change', applyDark); applyDark(); ``` {% endmarkdown %} {% endblock %}