collab/mermaid/docs/config/theming.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/theming.md](../../packages/mermaid/src/docs/config/theming.md).
6dd74de6
6dd74de7# Theme Configuration
6dd74de8
6dd74de9Dynamic and integrated theme configuration was introduced in Mermaid version 8.7.0.
6dd74de10
6dd74de11Themes can now be customized at the site-wide level, or on individual Mermaid diagrams. For site-wide theme customization, the `initialize` call is used. For diagram specific customization, frontmatter config is used.
6dd74de12
6dd74de13## Available Themes
6dd74de14
6dd74de151. [**default**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-default.js) - This is the default theme for all diagrams.
6dd74de16
6dd74de172. [**neutral**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-neutral.js) - This theme is great for black and white documents that will be printed.
6dd74de18
6dd74de193. [**dark**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-dark.js) - This theme goes well with dark-colored elements or dark-mode.
6dd74de20
6dd74de214. [**forest**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-forest.js) - This theme contains shades of green.
6dd74de22
6dd74de235. [**base**](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/themes/theme-base.js) - This is the only theme that can be modified. Use this theme as the base for customizations.
6dd74de24
6dd74de25## Site-wide Theme
6dd74de26
6dd74de27To customize themes site-wide, call the `initialize` method on the `mermaid`.
6dd74de28
6dd74de29Example of `initialize` call setting `theme` to `base`:
6dd74de30
6dd74de31```javascript
6dd74de32mermaid.initialize({
6dd74de33 securityLevel: 'loose',
6dd74de34 theme: 'base',
6dd74de35});
6dd74de36```
6dd74de37
6dd74de38## Diagram-specific Themes
6dd74de39
6dd74de40To customize the theme of an individual diagram, use frontmatter config.
6dd74de41
6dd74de42Example of frontmatter config setting the `theme` to `forest`:
6dd74de43
6dd74de44```mermaid-example
6dd74de45---
6dd74de46config:
6dd74de47 theme: 'forest'
6dd74de48---
6dd74de49 graph TD
6dd74de50 a --> b
6dd74de51```
6dd74de52
6dd74de53```mermaid
6dd74de54---
6dd74de55config:
6dd74de56 theme: 'forest'
6dd74de57---
6dd74de58 graph TD
6dd74de59 a --> b
6dd74de60```
6dd74de61
6dd74de62> **Reminder**: the only theme that can be customized is the `base` theme. The following section covers how to use `themeVariables` for customizations.
6dd74de63
6dd74de64## Customizing Themes with `themeVariables`
6dd74de65
6dd74de66To make a custom theme, modify `themeVariables` via frontmatter config.
6dd74de67
6dd74de68You will need to use the [base](#available-themes) theme as it is the only modifiable theme.
6dd74de69
6dd74de70| Parameter | Description | Type | Properties |
6dd74de71| -------------- | ---------------------------------- | ------ | ----------------------------------------------------------------------------------- |
6dd74de72| themeVariables | Modifiable with frontmatter config | Object | `primaryColor`, `primaryTextColor`, `lineColor` ([see full list](#theme-variables)) |
6dd74de73
6dd74de74Example of modifying `themeVariables` using frontmatter config:
6dd74de75
6dd74de76```mermaid-example
6dd74de77---
6dd74de78config:
6dd74de79 theme: 'base'
6dd74de80 themeVariables:
6dd74de81 primaryColor: '#BB2528'
6dd74de82 primaryTextColor: '#fff'
6dd74de83 primaryBorderColor: '#7C0000'
6dd74de84 lineColor: '#F8B229'
6dd74de85 secondaryColor: '#006100'
6dd74de86 tertiaryColor: '#fff'
6dd74de87---
6dd74de88 graph TD
6dd74de89 A[Christmas] -->|Get money| B(Go shopping)
6dd74de90 B --> C{Let me think}
6dd74de91 B --> G[/Another/]
6dd74de92 C ==>|One| D[Laptop]
6dd74de93 C -->|Two| E[iPhone]
6dd74de94 C -->|Three| F[fa:fa-car Car]
6dd74de95 subgraph section
6dd74de96 C
6dd74de97 D
6dd74de98 E
6dd74de99 F
6dd74de100 G
6dd74de101 end
6dd74de102```
6dd74de103
6dd74de104```mermaid
6dd74de105---
6dd74de106config:
6dd74de107 theme: 'base'
6dd74de108 themeVariables:
6dd74de109 primaryColor: '#BB2528'
6dd74de110 primaryTextColor: '#fff'
6dd74de111 primaryBorderColor: '#7C0000'
6dd74de112 lineColor: '#F8B229'
6dd74de113 secondaryColor: '#006100'
6dd74de114 tertiaryColor: '#fff'
6dd74de115---
6dd74de116 graph TD
6dd74de117 A[Christmas] -->|Get money| B(Go shopping)
6dd74de118 B --> C{Let me think}
6dd74de119 B --> G[/Another/]
6dd74de120 C ==>|One| D[Laptop]
6dd74de121 C -->|Two| E[iPhone]
6dd74de122 C -->|Three| F[fa:fa-car Car]
6dd74de123 subgraph section
6dd74de124 C
6dd74de125 D
6dd74de126 E
6dd74de127 F
6dd74de128 G
6dd74de129 end
6dd74de130```
6dd74de131
6dd74de132## Color and Color Calculation
6dd74de133
6dd74de134To ensure diagram readability, the default value of certain variables is calculated or derived from other variables. For example, `primaryBorderColor` is derived from the `primaryColor` variable. So if the `primaryColor` variable is customized, Mermaid will adjust `primaryBorderColor` automatically. Adjustments can mean a color inversion, a hue change, a darkening/lightening by 10%, etc.
6dd74de135
6dd74de136The theming engine will only recognize hex colors and not color names. So, the value `#ff0000` will work, but `red` will not.
6dd74de137
6dd74de138## Theme Variables
6dd74de139
6dd74de140| Variable | Default value | Description |
6dd74de141| -------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
6dd74de142| darkMode | false | Affects how derived colors are calculated. Set value to `true` for dark mode. |
6dd74de143| background | #f4f4f4 | Used to calculate color for items that should either be background colored or contrasting to the background |
6dd74de144| fontFamily | trebuchet ms, verdana, arial | Font family for diagram text |
6dd74de145| fontSize | 16px | Font size in pixels |
6dd74de146| primaryColor | #fff4dd | Color to be used as background in nodes, other colors will be derived from this |
6dd74de147| primaryTextColor | calculated from darkMode #ddd/#333 | Color to be used as text color in nodes using `primaryColor` |
6dd74de148| secondaryColor | calculated from primaryColor | |
6dd74de149| primaryBorderColor | calculated from primaryColor | Color to be used as border in nodes using `primaryColor` |
6dd74de150| secondaryBorderColor | calculated from secondaryColor | Color to be used as border in nodes using `secondaryColor` |
6dd74de151| secondaryTextColor | calculated from secondaryColor | Color to be used as text color in nodes using `secondaryColor` |
6dd74de152| tertiaryColor | calculated from primaryColor | |
6dd74de153| tertiaryBorderColor | calculated from tertiaryColor | Color to be used as border in nodes using `tertiaryColor` |
6dd74de154| tertiaryTextColor | calculated from tertiaryColor | Color to be used as text color in nodes using `tertiaryColor` |
6dd74de155| noteBkgColor | #fff5ad | Color used as background in notes |
6dd74de156| noteTextColor | #333 | Text color in note rectangles |
6dd74de157| noteBorderColor | calculated from noteBkgColor | Border color in note rectangles |
6dd74de158| lineColor | calculated from background | |
6dd74de159| textColor | calculated from primaryTextColor | Text in diagram over the background for instance text on labels and on signals in sequence diagram or the title in Gantt diagram |
6dd74de160| mainBkg | calculated from primaryColor | Background in flowchart objects like rects/circles, class diagram classes, sequence diagram etc |
6dd74de161| errorBkgColor | tertiaryColor | Color for syntax error message |
6dd74de162| errorTextColor | tertiaryTextColor | Color for syntax error message |
6dd74de163
6dd74de164## Flowchart Variables
6dd74de165
6dd74de166| Variable | Default value | Description |
6dd74de167| ------------------- | ------------------------------ | --------------------------- |
6dd74de168| nodeBorder | primaryBorderColor | Node Border Color |
6dd74de169| clusterBkg | tertiaryColor | Background in subgraphs |
6dd74de170| clusterBorder | tertiaryBorderColor | Cluster Border Color |
6dd74de171| defaultLinkColor | lineColor | Link Color |
6dd74de172| titleColor | tertiaryTextColor | Title Color |
6dd74de173| edgeLabelBackground | calculated from secondaryColor | |
6dd74de174| nodeTextColor | primaryTextColor | Color for text inside Nodes |
6dd74de175
6dd74de176## Sequence Diagram Variables
6dd74de177
6dd74de178| Variable | Default value | Description |
6dd74de179| --------------------- | ------------------------------ | --------------------------- |
6dd74de180| actorBkg | mainBkg | Actor Background Color |
6dd74de181| actorBorder | primaryBorderColor | Actor Border Color |
6dd74de182| actorTextColor | primaryTextColor | Actor Text Color |
6dd74de183| actorLineColor | actorBorder | Actor Line Color |
6dd74de184| signalColor | textColor | Signal Color |
6dd74de185| signalTextColor | textColor | Signal Text Color |
6dd74de186| labelBoxBkgColor | actorBkg | Label Box Background Color |
6dd74de187| labelBoxBorderColor | actorBorder | Label Box Border Color |
6dd74de188| labelTextColor | actorTextColor | Label Text Color |
6dd74de189| loopTextColor | actorTextColor | Loop Text Color |
6dd74de190| activationBorderColor | calculated from secondaryColor | Activation Border Color |
6dd74de191| activationBkgColor | secondaryColor | Activation Background Color |
6dd74de192| sequenceNumberColor | calculated from lineColor | Sequence Number Color |
6dd74de193
6dd74de194## Pie Diagram Variables
6dd74de195
6dd74de196| Variable | Default value | Description |
6dd74de197| ------------------- | ------------------------------ | ------------------------------------------ |
6dd74de198| pie1 | primaryColor | Fill for 1st section in pie diagram |
6dd74de199| pie2 | secondaryColor | Fill for 2nd section in pie diagram |
6dd74de200| pie3 | calculated from tertiary | Fill for 3rd section in pie diagram |
6dd74de201| pie4 | calculated from primaryColor | Fill for 4th section in pie diagram |
6dd74de202| pie5 | calculated from secondaryColor | Fill for 5th section in pie diagram |
6dd74de203| pie6 | calculated from tertiaryColor | Fill for 6th section in pie diagram |
6dd74de204| pie7 | calculated from primaryColor | Fill for 7th section in pie diagram |
6dd74de205| pie8 | calculated from primaryColor | Fill for 8th section in pie diagram |
6dd74de206| pie9 | calculated from primaryColor | Fill for 9th section in pie diagram |
6dd74de207| pie10 | calculated from primaryColor | Fill for 10th section in pie diagram |
6dd74de208| pie11 | calculated from primaryColor | Fill for 11th section in pie diagram |
6dd74de209| pie12 | calculated from primaryColor | Fill for 12th section in pie diagram |
6dd74de210| pieTitleTextSize | 25px | Title text size |
6dd74de211| pieTitleTextColor | taskTextDarkColor | Title text color |
6dd74de212| pieSectionTextSize | 17px | Text size of individual section labels |
6dd74de213| pieSectionTextColor | textColor | Text color of individual section labels |
6dd74de214| pieLegendTextSize | 17px | Text size of labels in diagram legend |
6dd74de215| pieLegendTextColor | taskTextDarkColor | Text color of labels in diagram legend |
6dd74de216| pieStrokeColor | black | Border color of individual pie sections |
6dd74de217| pieStrokeWidth | 2px | Border width of individual pie sections |
6dd74de218| pieOuterStrokeWidth | 2px | Border width of pie diagram's outer circle |
6dd74de219| pieOuterStrokeColor | black | Border color of pie diagram's outer circle |
6dd74de220| pieOpacity | 0.7 | Opacity of individual pie sections |
6dd74de221
6dd74de222## State Colors
6dd74de223
6dd74de224| Variable | Default value | Description |
6dd74de225| ------------- | ---------------- | -------------------------------------------- |
6dd74de226| labelColor | primaryTextColor | |
6dd74de227| altBackground | tertiaryColor | Used for background in deep composite states |
6dd74de228
6dd74de229## Class Colors
6dd74de230
6dd74de231| Variable | Default value | Description |
6dd74de232| --------- | ------------- | ------------------------------- |
6dd74de233| classText | textColor | Color of Text in class diagrams |
6dd74de234
6dd74de235## User Journey Colors
6dd74de236
6dd74de237| Variable | Default value | Description |
6dd74de238| --------- | ------------------------------ | --------------------------------------- |
6dd74de239| fillType0 | primaryColor | Fill for 1st section in journey diagram |
6dd74de240| fillType1 | secondaryColor | Fill for 2nd section in journey diagram |
6dd74de241| fillType2 | calculated from primaryColor | Fill for 3rd section in journey diagram |
6dd74de242| fillType3 | calculated from secondaryColor | Fill for 4th section in journey diagram |
6dd74de243| fillType4 | calculated from primaryColor | Fill for 5th section in journey diagram |
6dd74de244| fillType5 | calculated from secondaryColor | Fill for 6th section in journey diagram |
6dd74de245| fillType6 | calculated from primaryColor | Fill for 7th section in journey diagram |
6dd74de246| fillType7 | calculated from secondaryColor | Fill for 8th section in journey diagram |