reading the documentation https://mermaid.js.org/syntax/entityRelationshipDiagram.html#config-options
How is this style config applied? I would like to style the following diagram:
erDiagram
CAR ||--o{ NAMED-DRIVER : allows
CAR {
string registrationNumber
string make
string model
}
PERSON ||--o{ NAMED-DRIVER : is
PERSON {
string firstName
string lastName
int age
}
Explicitly I would like to color the registrationNumber
. How is this possible using the fill
option indicated in the documentation?
Here a link to the live editor: Mermaid Live Example
THX
The styling options defined by Mermaid seem not to apply to the individual entity attributes.
But you can prepend your Mermaid code with a preamble containing a themeCSS
configuration property. This can contain a CSS selector that relies on internals of the SVG being generated by the Mermaid renderer, specifically
id
attribute for an entity (entity-
followed by the entity name followed another hyphen and more)rect
boxes (the 2nd and 3rd make up the first entity attribute).<script type="module" src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs"></script>
<pre class="mermaid">
---
config:
themeCSS: |
[id|=entity-CAR] rect:nth-of-type(2),
[id|=entity-CAR] rect:nth-of-type(3)
{ fill: yellow; }
---
erDiagram
CAR ||--o{ NAMED-DRIVER : allows
CAR {
string registrationNumber
string make
string model
}
PERSON ||--o{ NAMED-DRIVER : is
PERSON {
string firstName
string lastName
int age
}
</pre>