Getting started

In order to enable the theme add the following line to your project’s project/plugins.sbt:

JDK 1.8

addSbtPlugin("com.github.sbt" % "sbt-paradox-material-theme" % "0.7.0")

JDK 11+

addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.10.6")
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-theme" % "0.10.6")
addSbtPlugin("com.github.sbt" % "sbt-paradox-material-theme" % "0.7.0")

And enable the theme plugin in your project’s build.sbt:

sourceenablePlugins(ParadoxMaterialThemePlugin)

Configuring the theme

The theme is configurable via Paradox properties which means that you can provide defaults in your project’s build.sbt and override properties in each page’s front matter. The preferred way to configure the theme is to use the utility the theme plugin provides which help configure the theme in a concise manner using a builder-like API:

sourceCompile / paradoxMaterialTheme := {
  ParadoxMaterialTheme()
    .withColor("red", "orange")
    .withLogoIcon("cloud")
    .withCopyright("Copyleft © Jonas Fonseca")
}

The examples given in the following sections use an alternative syntax. The equivalent of the above configuration using this alternative syntax is:

sourceCompile / paradoxMaterialTheme ~= {
  _.withColor("red", "orange")
    .withLogoIcon("cloud")
    .withCopyright("Copyleft © Jonas Fonseca")
}

In both cases, the theme’s configuration is added to the Paradox properties. As a result it is also possible to set properties directly using paradoxProperties or front matter. Front matter allows you to tweak the look-and-feel for specific pages. The equivalent of the above configuration can be defined in front matter as:

---
material.color.primary: red
material.color.accent: orange
material.logo.icon: cloud
material.copyright: Copyleft © Jonas Fonseca
---

See the following sections for available options.

Changing the color palette

A default hue is defined for every primary and accent color on Google’s Material Design color palette, which makes it very easy to change the overall look of the theme. Just set the primary and accent colors using the following variables:

sourceCompile / paradoxMaterialTheme ~= {
  _.withColor("teal", "indigo")
}

Color names are case-insensitive, but must match the names of the Material Design color palette. Valid values are: red, pink, purple, deep-purple, indigo, blue, light-blue, cyan, teal, green, light-green, lime, yellow, amber, orange, deep-orange, brown, grey, blue-grey and white. The last four colors can only be used as a primary color.

If the color is set via this configuration, an additional CSS file that defines the color palette is automatically included. If you want to keep things lean, clone the repository and recompile the theme with your custom colors set. See the guide on customization for more information.

Primary colors

Click on a tile to change the primary color of the theme:

Accent colors

Click on a tile to change the accent color of the theme:

Changing the font family

By default the Roboto font family is included with the theme, specifically the regular sans-serif type for text and the monospaced type for code. Both fonts are loaded from Google Fonts and can be changed to other fonts, like for example the Ubuntu font family:

sourceCompile / paradoxMaterialTheme ~= {
  _.withFont("Ubuntu", "Ubuntu Mono")
}

The text font will be loaded in weights 400 and 700, the monospaced font in regular weight. If you want to load fonts from other destinations or don’t want to use the Google Fonts loading magic, just set font to false:

sourceCompile / paradoxMaterialTheme ~= {
  _.withoutFont()
}

Adding a source repository

To include a link to the repository of your project within your documentation, set the following variables via your project’s build.sbt:

sourceCompile / paradoxMaterialTheme ~= {
  _.withRepository(uri("https://github.com/sbt/sbt-paradox-material-theme"))
}

The name of the repository will be rendered next to the search bar on big screens and as part of the main navigation drawer on smaller screen sizes. Furthermore, if the repository is hosted on GitHub, Bitbucker or Gitlab a logo of the service is shown next to the name of the repository. When the type is set to GitHub, the number of stars and forks is shown.

Why is there an edit button at the bottom of every article?

If github.base_url is set, an edit button will appear at the bottom of every article. This behaviour is provided by Paradox. See the Paradox documentation on more guidance regarding the $page.source_url$ attribute, which defines whether the edit button is shown or not.

Adding a favicon

A favicon can be changed by providing a path toto an .ico or image file:

sourceCompile / paradoxMaterialTheme ~= {
  _.withFavicon("assets/images/favicon.png")
}

Adding a logo

Your logo should have a rectangular shape with a minimum resolution of 128x128, leave some room towards the edges and be composed of high contrast areas on a transparent ground, as it will be placed on the colored header bar and drawer. Simply create the folder assets/images, add your logo and embed it with:

sourceCompile / paradoxMaterialTheme ~= {
  _.withLogo("assets/images/logo.png")
}

If you do not want to include the logo in your site you can also link to the logo using a URI:

sourceCompile / paradoxMaterialTheme ~= {
  _.withLogoUri(uri("https://example.org/logo.png"))
}

Additionally, the default icon can be changed by setting an arbitrary ligature (or Unicode code point) from the Material Design icon font, e.g.

sourceCompile / paradoxMaterialTheme ~= {
  _.withLogoIcon("cloud")
}

Adding social links

Social accounts can be linked in the footer of the documentation using an icon from the FontAwesome webfont. The icons are automatically detected based on the URL:

sourceCompile / paradoxMaterialTheme ~= {
  _.withSocial(
    uri("https://github.com/jonas"),
    uri("https://twitter.com/priorarts")
  )
}

Copyright Notice

To display a copyright notice in the footer configure the text you want to show. Any HTML markup, such as links, can be used:

sourceCompile / paradoxMaterialTheme ~= {
  _.withCopyright("""
    Based on <a href="https://github.com/squidfunk/mkdocs-material">MkDocs Material</a>
    by <a href="https://github.com/squidfunk">Martin Donath</a>
  """)
}

Language

You can define the language of your site:

sourceCompile / paradoxMaterialTheme ~= {
  _.withLanguage(java.util.Locale.ENGLISH)
}

This will add a lang attribute to the top-level html element:

<!DOCTYPE html>
<html lang="en" class="no-js">
  ...
</html>

If no language is set English (en) is assumed.

Site search

Site search is enabled by default and will automatically generate a search_index.json file that contains all your site’s content and add it to your site. If you want to disable search use:

sourceCompile / paradoxMaterialTheme ~= {
  _.withoutSearch()
}

Search tokenization

The separator for tokenization can also be customized, which makes it possible to index parts of words that are separated by - or . for example:

sourceCompile / paradoxMaterialTheme ~= {
  _.withSearch(tokenizer = "[\\s\\-\\.]+")
}

Google Analytics integration

The theme makes it easy to integrate site tracking with Google Analytics. Besides basic tracking, clicks on all outgoing links can be tracked as well as how site search is used. Tracking can be activated in your project’s build.sbt:

sourceCompile / paradoxMaterialTheme ~= {
  _.withGoogleAnalytics("UA-107934279-1") // Remember to change this!
}

More advanced customization

If you want to change the general appearance of the Material theme, see the customization guide for more information.