Customizing the Fairing SDK
Restyle the survey UI with CSS custom properties and class hooks, without forking the SDK.
Fairing's survey UI is styled with CSS custom properties and BEM-style class hooks, so you can match the look of your storefront without forking the SDK. This guide explains the token system, documents the class hooks, and shows worked examples you can drop into a stylesheet on your own pages.
Quickstart
The fastest restyle is a one-line change to the brand color. Every filled button, selected state, highlight and accent reads through the --fg-theme-brand-700 token, so overriding that one property cascades across the entire survey.
/* Drop into your site's stylesheet */
.fairing {
--fg-theme-brand-700: #1f7a3a;
--fg-theme-brand-800: #27904a;
--fg-theme-brand-900: #34a35b;
}Override on .fairing (the SDK's root element) to keep the change scoped. Nothing else on your page is affected.
The token system
Tokens are organized in two tiers. Theme scales hold raw color, type and spacing values. Semantic tokens reference those scales and are what the components actually consume.
/* Tier 1: theme scale (raw color rung) */
--fg-theme-brand-700: oklch(0.26 0.05 274.15);
/* Tier 2: semantic token (points at a scale rung) */
--fg-bg-fill-brand-primary: var(--fg-theme-brand-700);
/* Applied in a component rule */
.fairing__action--submit {
background-color: var(--fg-bg-fill-brand-primary);
}Most of the time you only need to touch tier 1: override the --fg-theme-brand-* scale and every semantic token downstream updates automatically. Reach for tier 2 when you need to change one surface in isolation, for example darkening the action bar background without recoloring fills.
Scope your overridesAlways set tokens on
.fairing, not:rootorbody. The SDK's root element acts as the token boundary, which keeps your customizations from leaking into the rest of your site.
Color tokens
Colors are expressed in OKLCH so lightness ramps stay perceptually even across hue shifts. You can override with any valid CSS color: oklch(), hsl() or hex.
Base scale (neutrals)
Used for surfaces, borders and body copy.
Brand scale
The default brand scale is a deep indigo. --fg-theme-brand-700 is the primary fill, -800 is hover and -900 is active. -100 through -300 drive subtle hover and tertiary surfaces.
Semantic color tokens
These are the higher-level tokens consumed by components. Override them when you need finer control than recoloring the brand scale.
| Token | Default | Used by |
|---|---|---|
--fg-bg-fill-brand-primary | brand-700 | Submit button, checked checkbox |
--fg-bg-fill-brand-primary-hover | brand-800 | Selected NPS button |
--fg-bg-fill-brand-primary-active | brand-900 | Active/pressed brand fills |
--fg-bg-fill-brand-tertiary-hover | brand-300 | NPS hover background |
--fg-bg-surface-brand-tertiary | brand-100 | Autosuggest hovered/selected option |
--fg-bg-surface-base-secondary | base-50 | Action bar, inputs, textarea |
--fg-bg-fill-danger-primary | danger-700 | Inline error notice |
--fg-border-base-primary | base-500 | Card, inputs, controls |
--fg-border-brand-primary-hover | brand-600 | NPS hover border |
--fg-border-brand-primary-active | brand-700 | Focus rings, checked controls |
--fg-text-base-primary | base-950 | Title, body copy, response labels |
--fg-text-base-secondary | base-900 | Description, branding link |
--fg-text-brand-active | brand-900 | Autosuggest selected option text |
--fg-text-brand-hover | brand-800 | NPS hover text |
--fg-text-overlay-w-primary | white | Text on filled brand surfaces |
Typography tokens
Font size and weight live on tokens too. Sizes use a clamp() plus container-query (cqi) formula so type scales fluidly inside the survey card. This keeps text readable in both inline embeds and full-screen modals.
| Token | Default | Used by |
|---|---|---|
--fg-font-size-xs | ~10–13 px | Powered-by branding |
--fg-font-size-sm | ~13–14 px | Error indicator |
--fg-font-size-md | 16 px | Body, labels, inputs, button |
--fg-font-size-lg | ~18–20 px | Success message |
--fg-font-size-xl | ~20–25 px | Question title |
--fg-font-weight-normal | 400 | Description, body |
--fg-font-weight-strong | 500 | Title, submit, success |
Setting a custom font familyFont family is not yet a token. Apply it directly to the
.fairingroot:.fairing { font-family: "Your Brand Serif", Georgia, serif; }. All survey text inherits from the root, so one declaration covers the entire SDK.
Spacing and shape
Spacing follows the same fluid-clamp pattern as type. Sticking to the existing scale keeps internal rhythm consistent. If you need slightly larger padding, bump the whole scale rather than tweaking individual rules.
| Token | Default |
|---|---|
--fg-space-3xs | 4–5 px |
--fg-space-2xs | 8–10 px |
--fg-space-xs | 12–15 px |
--fg-space-sm | 16–20 px |
--fg-space-md | 20–25 px |
--fg-space-lg | 24–30 px |
--fg-space-md-lg | 20–30 px (horizontal padding) |
--fg-space-2xl-3xl | 32–45 px (success message padding) |
--fg-radius-xs | 2–3 px (controls, inputs) |
--fg-radius-sm | 4–5 px (submit button) |
--fg-radius-md | 8–10 px (survey card) |
--fg-shadow-md | Card drop shadow in modal mode |
Class hooks
When a token isn't enough (for instance, you want a different border radius on the submit button but not the survey card), use the class hooks below. Every interactive element has a .fairing__* class you can target.
| Class | Element |
|---|---|
.fairing | Root container. Token overrides go here. |
.fairing-container | Outer container (inline embeds). |
.fairing-container--full-screen | Modal/overlay variant. |
.fairing-container--is-active | Applied while the survey is visible. |
.fairing__survey / .fairing-question | Survey card. |
.fairing-survey__title | Question prompt heading. |
.fairing__question-description | Sub-description copy. |
.fairing__responses | Wrapper around all response options. |
.fairing__response | One response row. |
.fairing__response-label | The clickable label text. |
.fairing__radio-control | Custom radio. |
.fairing__checkbox-control | Custom checkbox. |
.fairing__nps-controls / .fairing__nps-control | NPS button row and individual buttons. |
.fairing__nps-labels | 0–10 endpoint labels under NPS. |
.fairing__open-ended-response | Free-text textarea. |
.fairing__other-response | "Other" text input next to a radio. |
.fairing__date-response__input | Date picker fields. |
.fairing__autosuggest__input | Typeahead search input. |
.fairing__autosuggest__list | Typeahead dropdown panel. |
.fairing__autosuggest__option | One row in the dropdown. |
.fairing__autosuggest__highlight | Matched substring inside an option. |
.fairing__survey-actions | Footer bar (submit and branding). |
.fairing__action--submit | Primary submit button. |
.fairing__branding / .fairing__branding-link | "Powered by Fairing" line. |
.fairing__close-button | Dismiss button (modal mode only). |
.fairing__error-notice | Inline error banner. |
.fairing__success-message | Post-submit thank-you state. |
Data attribute hooks
The SDK also exposes a few data-* attributes for type-specific targeting:
[data-fairing-question-type="single_response"],"multi_response","open_ended","nps","date","autosuggest": on theform.[data-fg-component="fg-nps"],[data-fg-component="fg-autosuggest"]: on the responses container.[data-enquire-response="…"]: on each radio or checkbox, carrying the literal response value.
Recipes
1. Replace the full brand palette
For a polished restyle, set the whole brand ramp so hover, active and tertiary states all sit on the same hue.
.fairing {
--fg-theme-brand-100: #f7e8e3;
--fg-theme-brand-300: #e9c0b3;
--fg-theme-brand-600: #b5573a;
--fg-theme-brand-700: #7a2f1b;
--fg-theme-brand-800: #5d2314;
--fg-theme-brand-900: #3f180e;
}2. Match a serif brand
Apply your font family on .fairing and everything inherits. You can also nudge the title weight if your headline face needs a heavier cut.
.fairing {
font-family: "Caslon", Georgia, serif;
--fg-font-weight-strong: 600;
}
.fairing .fairing-survey__title {
letter-spacing: -0.01em;
}3. Soften (or sharpen) corners
Update the radius tokens together so all rounded elements stay consistent. Set them to 0 for a hard-edged editorial look.
.fairing {
--fg-radius-xs: 0;
--fg-radius-sm: 0;
--fg-radius-md: 0;
}
.fairing .fairing__survey {
border-color: #111;
border-width: 2px;
}4. Dark mode
Recolor surfaces and text together. The cleanest path is to invert the base scale so the SDK's built-in selectors keep doing the right thing.
.fairing {
--fg-theme-base-50: #1a1d22; /* action bar, inputs */
--fg-theme-base-500: #3b424d; /* borders */
--fg-theme-base-900: #c5cbd3; /* secondary text */
--fg-theme-base-950: #f3f5f7; /* primary text */
}
.fairing .fairing__survey {
background: #0f1115;
}5. Custom submit button shape
When you want one element to break from the system, such as a pill-shaped CTA, target its class hook directly. Keep the change scoped under .fairing so you don't override unrelated buttons on your page.
.fairing .fairing__action--submit {
border-radius: 9999px;
letter-spacing: 0.08em;
text-transform: uppercase;
font-size: 13px;
padding: 12px 28px;
}6. Restyle the modal backdrop
The full-screen variant adds .fairing-container--full-screen. Override its background color to tint the page dim differently, for example a darker scrim that matches your site's modal style.
.fairing.fairing-container--full-screen {
background-color: rgba(15, 17, 21, 0.72);
backdrop-filter: blur(4px);
}
.fairing .fairing__survey {
border-radius: 14px;
}Anatomy of a rendered survey
For reference, this is the markup the SDK injects for a single-response question. The same skeleton applies to every question type, with the responses container adapting to the type.
<div class="fairing fairing-container fairing-container--is-active">
<form class="fairing__survey" data-fairing-question-type="single_response">
<h2 class="fairing-survey__title">How did you hear about us?</h2>
<p class="fairing__question-description">We'd love to know.</p>
<div class="fairing__responses">
<div class="fairing__response">
<input type="radio"
class="fairing__radio-control"
data-enquire-response="Web Search">
<label class="fairing__response-label">Web Search</label>
</div>
<!-- more .fairing__response rows -->
</div>
<div class="fairing__survey-actions">
<button class="fairing__action--submit">Submit</button>
<p class="fairing__branding">
Powered by <a class="fairing__branding-link">Fairing</a>
</p>
</div>
</form>
</div>Caveats and tips
Stick to the token API where you can
Tokens are stable: they're part of the SDK's public contract. Internal selectors (anything not listed in the class hooks table above) can change between releases, so prefer a token override before reaching for a selector override.
Don't fight the container queries
Type and spacing scale with the survey container, not the viewport. If you hard-code font sizes you'll lose the fluid behavior. Use the --fg-font-size-* tokens or keep your overrides relative (em / %).
Specificity
The SDK's own rules use a single class of specificity. Any compound selector starting with .fairing (for example .fairing .fairing__action--submit) wins cleanly without !important.
Load order
fairing.js inserts its <link rel="stylesheet"> before the first existing stylesheet on the page, and appends to <head> only when no stylesheets are present yet. That means your site's own styles cascade after the SDK's, so an override of equal specificity wins without !important or specificity hacks. You can put your overrides in any stylesheet your page already loads.
Questions?Email [email protected] with a screenshot of the look you're going for and we'll send back a tested override snippet.
Token names and class hooks reflect SDK v1 as currently shipped.
Updated about 5 hours ago
