FormWork documentation
Advanced Theming
Override saved embed themes with CSS variables and understand theme precedence.
Most teams should style in the Appearance editor. Use this page when a host application needs code-level control.
Precedence
The client resolves presentation in this order:
- A web component
themeattribute overrides the saved mode. --formwork-*variables set on the host element override saved values.- Saved form-version values apply next.
- Built-in defaults fill anything unset.
Force the mode
<formwork-form form-id="FORM_ID" theme="dark"></formwork-form>
Accepted values are auto, light, and dark. Invalid values are normalised to auto.
Colour variables
Each colour exists for both light and dark. Replace {mode} with either word:
| Variable | Purpose |
|---|---|
--formwork-{mode}-primary | Buttons, focus, active accents |
--formwork-{mode}-bg | Outer background |
--formwork-{mode}-card-bg | Form/control surfaces |
--formwork-{mode}-text-primary | Main text |
--formwork-{mode}-text-secondary | Supporting text |
--formwork-{mode}-text-tertiary | Muted text |
--formwork-{mode}-border | Main borders |
--formwork-{mode}-border-light | Subtle dividers/borders |
--formwork-{mode}-error | Error text and borders |
--formwork-{mode}-error-bg | Error surface |
Layout and type variables
| Variable | Example | Purpose |
|---|---|---|
--formwork-spacing | 10px | Base spacing scale |
--formwork-radius | 8px | General corner radius |
--formwork-radius-full | 50% | Repeater action radius |
--formwork-font-family | Inter, sans-serif | Body font stack |
--formwork-font-family-headings | Georgia, serif | Heading font stack |
--formwork-max-width | 720px | Form maximum width |
Example override
<style>
#support-form {
--formwork-light-primary: #0f766e;
--formwork-dark-primary: #2dd4bf;
--formwork-light-bg: #f8fafc;
--formwork-light-card-bg: #ffffff;
--formwork-light-text-primary: #0f172a;
--formwork-light-border: #cbd5e1;
--formwork-radius: 4px;
--formwork-font-family: Inter, sans-serif;
--formwork-max-width: 720px;
}
</style>
<formwork-form id="support-form" form-id="FORM_ID"></formwork-form>
<script src="https://app.useformwork.com/static/client.js" type="module"></script>
Shadow and light DOM
The default render mode uses an open shadow root. Variables set on the host cross that boundary, but ordinary host selectors do not style internal elements.
Set render-mode="light" only when the form must participate in the page’s light DOM. The component still injects its own client stylesheet, and broad host-page selectors can then affect it, so test for CSS collisions.
<formwork-form form-id="FORM_ID" render-mode="light"></formwork-form>
Troubleshooting
| Symptom | Check |
|---|---|
| Saved colours do not appear | Look for host variables overriding them. |
| Auto always looks light | Confirm the device/browser dark preference and test the builder simulation. |
| Inner CSS selectors have no effect | Default shadow DOM isolates internals; use variables or intentional light DOM. |
| Custom font falls back | Make sure the host loads that font, unless it is one of the Appearance editor’s Google Fonts. |
| Draft and live look different | Appearance is versioned; compare the draft and published version settings. |