Styles
Bold, italic and a link are the same on every site. The things that make your site look like itself — a lead paragraph, a pull quote, a highlighted run of words — are yours, and Mason had no way to reach them. An author could not apply one without knowing a class name and typing it from memory.
A style is a name for one of your CSS classes. You define the list once; authors pick from it.
Defining them
Add-Ons → Mason → Styles.
Each style has a label, which is what authors see in the menu, and a class, which is what
lands in the markup. "Lead paragraph" → lead. Nothing else.
Below the list is a box for CSS. What you write there does two jobs:
- It is loaded into the editor, so a style looks like something while the entry is being written rather than being an invisible label.
- It is served on your site, so a style you invent here works without editing your theme's stylesheet.
The CSS in that box is scoped to the editor canvas inside the control panel. It cannot restyle the
control panel itself, however broadly it is written — body { background: red } is confined to the
canvas. A few things are removed when it is saved, and Mason tells you which:
@importis not followed. Add the stylesheet to the Stylesheets list instead.@font-faceand@keyframesare kept, but they apply control-panel-wide, because scoping them is not possible. Only their names leak; nothing is restyled.
Stylesheets
If your site already has the CSS, there is no reason to write it twice. Add its URL to Stylesheets and the editor previews against the real thing.
These are read by the server when you save, not by your browser, so it does not matter whether your site sends CORS headers. They are loaded into the editor only — your site already has them.
Using them
Select a run of words, open the Styles menu in the toolbar, and pick one. The class lands on those words:
<p>The <span class="lead">opening sentence</span> of the article.</p>
The menu shows which style is on the current selection, and Clear style removes it. A style replaces whatever style was there before rather than nesting inside it, and it combines freely with bold, italic and the rest.
Two things it will not do. It is disabled with nothing selected, because a style needs a run of words to attach to. And it is disabled inside inline code, which by definition excludes every other kind of formatting.
Styles are available in the main editor and inside a brick's rich-text field, from the same list. They appear on the Full toolbar; on a custom toolbar, tick Styles menu.
A field already saved with a custom toolbar will not show the menu until you open its settings and save them again — a custom toolbar is an explicit list, and Mason will not add to it behind your back.
On your site
The CSS is output automatically, so a new style works with no template change at all.
Better, though, is to put it in your <head>, where a stylesheet belongs:
{exp:mason:styles}
Then tick I include the tag in my own templates on the Styles screen, so it is not emitted twice.
If you change a style and the site does not change, clear your template cache — EE caches the parsed output of a template, and the style block is part of it.
Deleting a style
Deleting a style removes it from the menu. It does not go back through your entries and strip the class out of content that already uses it — that content still renders exactly as before, and if the CSS is still in your theme it still looks right.
Where a run of words carries a style that is no longer in the list, the menu says so, showing Unknown style and the class it is carrying, so an author can see what is there and clear it.
What a class may contain
Letters, digits, and _ - : / % . [ ] # ( ) , — which covers ordinary class names and Tailwind
utilities like md:text-lg, w-1/2 and text-[#bada55].
Quotes, angle brackets, ampersands and braces are refused. A class using one is dropped rather than rewritten into something that would not have matched your stylesheet anyway, and the Styles screen tells you at the time rather than letting you discover it on the site.
A style may apply up to 8 classes at once.
Styles and the per-block class tool
These are different tools and both are worth having.
A style is inline, chosen from a list, and applies to the words you select. The .class and
style tools inside a brick's rich-text field are freeform, apply to the whole block the cursor
is in, and expect you to know what you want. One is for the vocabulary your site has; the other is
the escape hatch for the thing it does not.