Developers
Theming with CSS
Override an embedded form's colours, fonts and spacing with CSS variables, choose light or dark mode, and decide whether the form renders in a shadow root.
Most teams should style forms in Appearance, which needs no code and also styles the hosted form link. Use this page when the page you embed the form in needs to control its look in code.

What wins
The embedded form works out each value in this order:
- The
themeattribute on<formwork-form>sets the mode, overriding the mode saved in Appearance. --formwork-*variables set on the<formwork-form>element override the saved values.- Values saved in Appearance for the form version apply next.
- Built-in defaults fill in anything else.
Appearance is part of the form version, so a draft and the published form can look different until you publish. See Drafts and publishing.
Choose light or dark
<formwork-form form-id="FORM_ID" theme="dark"></formwork-form>
| Value | Result |
|---|---|
auto | Follows the visitor’s light or dark setting |
light | Always light |
dark | Always dark |
Any other value is treated as auto. You can change the attribute at any time and the form updates.
Colour variables
Each colour has a light and a dark version. Replace {mode} with light or dark, for example --formwork-dark-primary.
| Variable | Used for | Light default | Dark default |
|---|---|---|---|
--formwork-{mode}-primary | Buttons, focus rings and highlights | #374151 | #dbe2e7 |
--formwork-{mode}-bg | Background around the form | transparent | #111820 |
--formwork-{mode}-card-bg | Form and control surfaces | #ffffff | #1f2933 |
--formwork-{mode}-text-primary | Main text | #1f2933 | #f4f7f8 |
--formwork-{mode}-text-secondary | Supporting text | #5f6c76 | #c3ccd2 |
--formwork-{mode}-text-tertiary | Muted text | #65737d | #94a0a9 |
--formwork-{mode}-border | Borders | #d7dde2 | #3d4a54 |
--formwork-{mode}-border-light | Subtle dividers | #eef2f4 | #2c3740 |
--formwork-{mode}-error | Error text and borders | #b42318 | #ff8a7a |
--formwork-{mode}-error-bg | Error backgrounds | #fff4f2 | #2b1a17 |
--formwork-{mode}-shadow | Card shadow | A soft shadow | A soft shadow |
--formwork-{mode}-shadow-sm | Small control shadow | None | None |
Hover and tinted versions of the primary and error colours are worked out from these, so you don’t set them separately.
Layout and type variables
These apply in both modes.
| Variable | Used for | Default |
|---|---|---|
--formwork-spacing | Base spacing unit. Other gaps are multiples of it. | 8px |
--formwork-radius | Corner radius. Smaller and larger corners are worked out from it. | 7px |
--formwork-radius-full | Round buttons, such as those on repeating items | 50% |
--formwork-font-family | Body text | The system font |
--formwork-font-family-headings | Headings | Same as the body font |
--formwork-max-width | Maximum width of the form | 680px |
--formwork-scroll-offset | Space to leave at the top when the form scrolls into view, for sticky headers | 0px |
Fonts set with these variables must be loaded by your page. FormWork only loads the Google Fonts you choose in Appearance.
Example
<style>
#support-form {
--formwork-light-primary: #0f766e;
--formwork-dark-primary: #2dd4bf;
--formwork-light-bg: #f8fafc;
--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>
Set the variables on the <formwork-form> element itself or on an ancestor. Setting a light value has no effect while the form is in dark mode, so set both versions of a colour if visitors can see either mode.
Shadow DOM and light DOM
By default the form renders inside a shadow root. CSS variables cross into it, but your page’s other selectors don’t, so site styles can’t break the form and you can’t restyle individual controls.
Set render-mode="light" only when the form must be part of the page’s normal DOM. The form still brings its own stylesheet, but broad selectors on your page can now affect it, so test carefully.
<formwork-form form-id="FORM_ID" render-mode="light"></formwork-form>
Class names and the internal structure of the form are not a supported interface and may change. Style through the variables above.
Troubleshooting
| Problem | Check |
|---|---|
| Colours from Appearance don’t show | Look for --formwork-* variables on the element or an ancestor that override them. |
auto always looks light | Check the device’s dark mode setting. |
| Your selectors have no effect | The shadow root isolates the form. Use variables, or light DOM on purpose. |
| A custom font falls back | Your page must load the font, unless it is one of the Appearance fonts. |
| The draft and live form look different | Appearance is saved per version. Publish the draft to apply its appearance. |