Skip to content

Colours and choices

Colour and choice fields don’t fill content. They change styles and attributes on marked elements, so marketers can adjust a module’s look without touching its code.

Both work with targets. A target is a marked element plus either a CSS style property (such as background-color) or an HTML attribute (such as bgcolor or align).

A colour field sets one colour on each of its targets. Marketers pick it with a colour picker or type a hex value.

<td data-mm="background" bgcolor="#18181b" style="border-radius:6px;background-color:#18181b">
<a data-mm="button" href="https://example.com" style="color:#ffffff">Find out more</a>
</td>

Set up the colour field with two targets on the same marker:

MarkerSets
backgroundStyle property background-color
backgroundAttribute bgcolor

When you add a second target after background-color, Modular Mail suggests bgcolor on the same marker, since Outlook for Windows reads the attribute rather than the style.

Colours must be hex values: #rgb or #rrggbb. Turn on Required if the field must have a value. Otherwise, an empty colour leaves the HTML as written.

A choice field offers a set of named options. Each option gives its targets a value. Marketers see buttons when there are up to three short options, and a dropdown when there are more.

Use a choice for anything with a fixed set of approved answers: alignment, image side, spacing, a light or dark style, a brand colour.

<td data-mm="cell" align="left" style="padding:16px 32px">
…a button…
</td>
OptionTargetValue
Leftcell, attribute alignleft
Centrecell, attribute aligncenter
Rightcell, attribute alignright

The dir attribute swaps the order of table cells without changing the HTML. Mark the table and give each option a dir value:

<table data-mm="columns" role="presentation" dir="ltr" width="100%">
<tr>
<td class="stack" dir="ltr" width="260">…image…</td>
<td class="stack" dir="ltr">…text…</td>
</tr>
</table>
OptionTargetValue
Leftcolumns, attribute dirltr
Rightcolumns, attribute dirrtl

Set dir="ltr" on the cells too, so their text still reads left to right.

One option can set several targets at once, which makes a style preset. A “Dark” option might set a section’s background colour, its bgcolor and its text colour together:

TargetLightDark
section, style background-color#ffffff#18181b
section, attribute bgcolor#ffffff#18181b
heading, style color#18181b#ffffff
body, style color#3f3f46#d4d4d8

An option with no value for a target leaves that target as the HTML has it, shown as As written in the settings. This lets the first option be “as designed” with nothing to fill in.

  1. Add a Choice field and give it a label, such as “Alignment”.
  2. Under Sets, add a target for each style or attribute the options change: pick the marker, then Style property or Attribute, and its name.
  3. Under Options, give each option a label and a value for each target.
  4. Pick the Default option, the one new modules start with.

Values can’t contain ;, ", <, >, braces or line breaks. Attributes can’t be style (use a style property instead), data-mm or event handlers such as onclick.