Styling contract
Overview
Every storefront form carries a small, versioned set of data-wf-* attributes and --wf-* CSS custom
properties. They are the names WebForms promises to keep: CSS written against them survives template changes,
and the same names appear on Luma, Hyvä and Breeze. The class names in the markup are not part of the promise
and may change between releases.
The contract is declared in one place, MageMe\WebForms\Model\Contract\StylingContract, and printed by
MageMe\WebForms\Model\Contract\PartAttributes. The current version is 1. The version goes up only for a
breaking change: a part removed, moved to another node or given a new meaning.
How to read the rules below:
data-wf-partholds a space-separated list, because one node can play several roles (a Phone field's input carriesdata-wf-part="field-input phone"). Match it with~=, not=.- Containment is part of the promise: a field's label, control, input, hint and error sit inside that field; a
section's heading and subtitle sit inside the section; a button sits inside the row that holds it. How many
wrappers lie between them isn't promised.
messagesis the exception: it renders beside the form element, not inside it. A selector that starts at the root, such as[data-wf-contract="1"] …, never reaches it; select it with[data-wf-part~="messages"]on its own. - On Luma and Breeze, put your rules in the theme hook file. On Hyvä, put them in your theme's own stylesheet. See Theme and template overrides.
[data-wf-contract="1"] [data-wf-part~="field"][data-wf-field-type="textarea"] [data-wf-part~="field-label"] {
font-weight: 600;
}
Root attributes
The form root is the <form> element. It carries these attributes on every stack.
| Attribute | What it holds | Notes |
|---|---|---|
data-wf-part | form | On a multi-step form with the Progress bar or Side steps indicator, the root also carries step-card. |
data-wf-contract | The contract version, 1 | Pin your rules to it if they should stop matching after a breaking change. messages sits outside the root and can't be pinned this way. |
data-wf-form | The form's Code | Printed only when the code is a CSS identifier: a letter, then letters, digits, _ or -, up to 100 characters. A form without a code gets no data-wf-form. |
Parts
The values of data-wf-part. Max is the limit the contract declares. For a part that lives inside a field,
section, step or row, the limit applies inside that container.
| Part | Node | Max |
|---|---|---|
form | The form wrapper. Carries the contract version and the appearance tokens. | 1 |
section | A visual group of fields. | Any |
section-heading | The section's heading, inside the section. | 1 |
section-subtitle | The section's subtitle, inside the section. | 1 |
zone | A container for elements outside every section. data-wf-zone says above or below. | 2 |
field | The outer wrapper of one field. data-wf-field-type carries its type. | Any |
field-label | The field's label element. | 1 |
field-control | The container of the input, not the input itself. | 1 |
field-input | The input, select or textarea. Composite fields have several. | Any |
field-hint | The field's help text. | 1 |
field-error | The field's validation message. | 1 |
actions | A row holding one action. data-wf-actions is submit or link. | Any |
actions-primary | The wrapper between the row and its button, where one exists. It sizes the button. | 1 |
submit | The submit button itself. | 1 |
link-action | A button-shaped link. | 1 |
captcha | The captcha widget container. It stays empty until a widget renders, so :empty is its state. | 1 |
messages | Form-level messages: success and submission errors. Beside the form element, not inside it. | 1 |
wizard | The multi-step container. data-wf-indicator says which progress indicator is on. | 1 |
wizard-empty | What a multi-step form says when its rules leave no step to show. | 1 |
step-strip | The list of steps. Present whichever indicator is chosen. | 1 |
step | One step in the strip. Its state is current, done or error. | Any |
step-label | The step's name, inside the step. | Any |
step-desc | The step's description, inside the step. | Any |
step-panel | The panel holding one step's fields. The panel on screen carries current. | Any |
step-panel-title | The panel's own heading, inside the panel. | Any |
step-card | The surface the panels are drawn on: a node under the strip for Numbered steps and Step tabs, the form root itself for Side steps and Progress bar. | 1 |
step-progress | The progress-bar widget of the Progress bar indicator. Its insides aren't part of the contract. | 1 |
step-nav | The row that moves between steps. On a multi-step form it holds the submit button. | 1 |
step-back | The button back to the previous step. | 1 |
step-next | The button on to the next step. | 1 |
step-finish | The button that sends the form. It carries submit as well. | 1 |
step-submit | The seat of the send button in the navigation row. | 1 |
callout | The callout component inside its field. | 1 |
terms | The agreement component inside its field. | 1 |
swatches | The swatch picker inside its field. | 1 |
grid | The dynamic grid inside its field. | 1 |
phone | The phone input with its country picker. | 1 |
signature | The signature pad inside its field. | 1 |
rating | The rating control inside its field. | 1 |
password-meter | The strength meter inside a password field. | 1 |
password-confirm | The confirming second input of a password field. It carries field-input as well. | 1 |
For the self-contained widgets, from callout to password-confirm, the contract names the widget and never its
insides.
Identity attributes
| Attribute | On | Value |
|---|---|---|
data-wf-field-type | field | The field type code, for example email, textarea, select_radio or phone_number. |
data-wf-field | field | The field's Field Code. |
data-wf-zone | zone | above or below. |
data-wf-actions | actions | submit for the submit row, link for a link button. |
data-wf-adjacent | section | actions on the section the action row sits under. Sections have no code, so this is how you address "the last section". |
data-wf-indicator | wizard | bar (Progress bar), numbers (Numbered steps), steps (Step tabs) or rail (Side steps). A form that stored the withdrawn value none keeps it. |
A value that isn't a CSS identifier isn't printed. data-wf-form and data-wf-field are also dropped when the
same value already appeared on the same form, so a selector never matches two nodes. Field types and zones repeat
by design.
States
data-wf-state holds a space-separated list. Match it with ~=.
| State | On | Set when |
|---|---|---|
required | field | The field is required. |
hidden-by-logic | field, section | A conditional logic rule hides it. The page prints it at render time and the logic script keeps it current. |
current | step, step-panel | The step on screen. |
done | step | A step the visitor has completed. |
error | step | A step with a validation error. |
The browser already exposes :disabled, :invalid and [aria-invalid], so the contract has no states for them.
Custom properties
All tokens land on the form root. A declaration on an ancestor is inherited, so it loses to anything declared on
the root itself. The Appearance settings print their values into the root's style attribute, and so does the
form's CSS Style setting. With default settings, the root carries
style="--wf-input-radius:8px".
| Token | Set by | Fallback | Notes |
|---|---|---|---|
--wf-input-accent | Accent Color | The stylesheet's own accent | Field style. |
--wf-input-border | Input Border Color | The stylesheet's own border | Field style. The Dark color scheme declares its own value, so an override there has to outweigh .mm-scheme-dark. |
--wf-input-placeholder | Placeholder Color | The stylesheet's own placeholder color | Field style. Same Dark scheme rule as the border. |
--wf-input-radius | Input Corner Radius | 8px | Field style. A length in pixels. |
--wf-input-height | Input Height | Not printed: fields take --wf-control-height | Field style. A length in pixels. Sizes the fields only; buttons keep --wf-control-height. |
--wf-heading | Heading Color | The stylesheet's own heading color | Field style. A section with its own background picks a readable heading color itself. |
--wf-label | Label Color | The stylesheet's own label color | Field style. A section with its own background picks readable label colors itself. Option captions take the surrounding text color. |
--wf-error | Error Color | red | Applies in every field style, not only Modern. |
--wf-form-step-accent | Active Step Color | The stylesheet's own step accent | Multi-step forms. |
--wf-form-step-done | Completed Step Color | The stylesheet's own done color | Multi-step forms. |
--wf-form-step-rail | Line Color | The stylesheet's own rail color | Multi-step forms. |
--wf-card-pad-y | Vertical Padding under Form Box | 0px | How far a full-width child travels to reach the card edge. The card of the Progress bar and Side steps indicators sets its own default. |
--wf-card-pad-x | Horizontal Padding under Form Box | 0px | As above. |
--wf-card-bg | Your theme only | transparent | The surface of the multi-step card. A Form Box background, when set, rides on the inline style and wins. |
--wf-gap-section | The product's stylesheet | 32px | The gap between sections. The product declares it on the root, so your rule has to outweigh that rule. |
--wf-gap-field | The product's stylesheet | 20px | The gap between fields. Same rule as the section gap. |
--wf-control-height | The product's stylesheet | 44px | The height of single-line fields and dropdowns (unless Input Height is set), the submit button, link buttons and the multi-step Back and Continue buttons. The submit button's Large and Extra Large sizes stay 8px and 16px above it. The product declares it on form.mm-fields-modern; override it with .webforms form.mm-fields-modern. Has no effect while the Modern style is off. |
The settings are under Stores → Configuration → MageMe Extensions → WebForms → Appearance. See Settings: Appearance.
- An Appearance value of the wrong type is dropped before it reaches the page: a color token takes a color, a pixel token a length in pixels.
- On Luma and Breeze the field-style tokens, the first seven rows, take effect only while Enable Modern Field Style is Yes. With it off, your theme styles the fields. On Hyvä the companion's classes read the tokens whatever that switch says.
- A token the settings leave empty isn't printed, so a declaration on the root in your stylesheet sets it. A
token the settings print sits in the inline
styleand outranks your stylesheet. Change the setting instead, or use the form's CSS Style setting for one form. - Other
--wf-*names in the markup, such as--wf-input-bg,--wf-wand--wf-slide-out-*, are internal and may change.
[data-wf-part~="form"] {
--wf-card-bg: #f7f3ee;
--wf-input-accent: #8a5a2b;
}
To make the fields and buttons of every Modern form 48px high, for example to line them up with theme buttons
of that height:
.webforms form.mm-fields-modern {
--wf-control-height: 48px;
}
On Hyvä, keep this rule outside any @layer and in a stylesheet compiled after the module styles.
Authored text
The texts a store owner writes are printed inside a wrapper with the class webforms-authored-html: the form's
description, the text below the form, the success text, an HTML field shown through the sanitiser, and the
messages of a conversation in My Account. The success dialog of a form that stays on the page (.mm-swal__html)
gets the same rule:
.webforms-authored-html,
.mm-swal__html {
transform: translate(0);
clip-path: inset(-8px);
}
The text keeps the classes its author gave it, but none of them can lay the text over the page:
- An element the text positions as
fixedorabsoluteis placed against the wrapper, not the window. - Anything that reaches more than 8px outside the wrapper is cut off. A dropdown menu or a tooltip written into a form text stays inside the text's box; the 8px leave room for a link's focus ring.
- The wrapper starts no new formatting context, so the text's margins fall as before.
On Hyvä the rule comes with the companion's styles (authored-text.css, outside any @layer). After you update the
WebForms Hyvä package, rebuild your theme's styles so the rule reaches the page.
What's next
- Theme and template overrides: where these rules go on Luma, Hyvä and Breeze, and how to replace a template.
- Frontend APIs: the storefront JavaScript, including the scripts that keep
hidden-by-logicand the step states current. - Settings: Appearance: the store owner's side of the same tokens.
- Make forms look like your theme: hand fields and buttons to your theme instead of restyling them.