Custom CSS overrides

Using CSS directly to style form layout and components

The style settings available within the theme editor are mostly simple wrappers around the CSS properties that are applied to the HTML elements rendered by Formsort. In simple terms, the options you see in the theme editor are easy-to-use controls for changing the appearance of your forms.

If you'd prefer to use CSS syntax directly to style your forms, you can do so by heading to Theme > General > Content area > Custom CSS and entering valid CSS rules there.

CSS overrides are an escape hatch! Please use our theme editor tools as much as possible.

Guide for use

Targeting specific groups and steps

You should first add ids to the steps and groups you want to customize - see our step id and group id documentation for more details.

After setting ids, you can use data-current-step-id and data-current-group-id attributes to target those steps and groups:

[data-current-group-id="contact details"] .fs__inputInner {
  border-radius: .5em;
}

[data-current-step-id="final step"] h2 {
  font-weight: bold;
}

Targeting components

When writing custom CSS rules, please use the supported classnames listed in the Class Reference section below to target specific component types and their elements.

  • Don't use random-seeming classnames or IDs you may find within the Formsort HTML structure. These should be considered implementation details and are subject to change at any time.

  • Don't use highly-nested selectors. We may, from time to time, change the DOM structure of layouts and components. Highly-nested selectors are brittle and subject to breaking when this happens.


Classname reference

Step layout Overrides

.fs__stepContent

This component is the container that wraps step content, question and informational blocks. It is a good choice to override some alignment, padding and font properties that effect whole step.

For example, if you want to change color of labels in a step, you could use this snippet.

.fs__stepContent label {
    color: cornflowerblue;
}

You should not override background color or image in this class name. As you can see in the image below, it can have margins around. We'll add fs__step later so that you can override the whole page styles.


Question and Component Overrides

Comparison cards

.fs__comparison-question

Targets the comparison card div. Can be used to set the alignment and justification of the comparison cards in their row.

.fs__comparisonCard

Targets the comparison card container. You can set overrides for components within the card such as font, alignment etc. Also you can use this class name to set gradient backgrounds and adjust positioning like margins and paddings.

The card content consists of 3 parts: title, body, and action containers:

  • .fs__comparisonCardTitle to style title section.

  • .fs__comparisonCardBody to style body section.

  • .fs__comparisonCardAction to style action button section.

To customize highlighted and selected states, you can use .fs__highlighted and .fs__selected class names, e.g.

.fs__comparisonCard.fs__selected .fs__comparisonCardBody {
    font-weight: bold;
}

Dividers

.fs__divider

You can set divider color with background-color, height, margins, etc.


Select component

Buttons

.fs__sb-container

Targets the entire Select component wrapper. The Select button container uses the display: flex property to order the container.

  • Use to style all select questions that are using buttons.

  • Use to override the layout of a specific Select question (in conjunction with step targeting).

.fs__sb-checkmark

Use this to target select buttons that use checkmarks.

.fs__sb-image

Use this to target select buttons that use images.

When a select question is turned into a dropdown, the dropdown will consist of 3 parts: container, list, and list items.

You can use .fs__dropdown-container to apply style overrides to both input and list, such as text alignment and font style. To drill down to the dropdown list and items, you can use .fs__dropdown-list and .fs__dropdown-list-item.

.fs__dropdown-container {
    font-weight: bold;
    text-align: center;
}

.fs__dropdown-list {
    margin-top: 24px; /* more space between input and list */
    background-color: lightyellow;
}

.fs__dropdown-list-item {
    margin-bottom: 8px;
    padding: 4px 8px;
}

.fs__dropdown-container

.fs__dropdown-list

.fs__dropdown-list-item

To customize highlighted, selected and disabled styles of list items, you can use common Formsort class names: .fs__highlighted, .fs__selected and .fs__disabled.

.fs__dropdown-list-item.fs__highlighted {
    border-color: deepskyblue;
}

.fs__dropdown-list-item.fs__selected {
    background-color: mediumpurple;
    color: white;
}

Text inputs

For most of input styles you can use .fs__inputInner. Use .fs__inputWrapper for margins and widths.

.fs__inputInner {
    background-color: aquamarine;
    padding: 8px;
    ...
}

.fs__inputWrapper {
    margin-bottom: 16px;
    max-width: 80%;
}

For input prefixes and suffixes, you can use .fs__inputPrefix and .fs__inputSuffix.

.fs__inputPrefix {
    padding-right: 24px;
}

.fs__inputSuffix {
    font-style: italic;
}

Just like in plain CSS, you can use pseudo-classes to customize input states like focus, hover, disabled and invalid.

.fs__inputInner:hover, .fs__inputInner:focus {
    background-color: purple;
}

.fs__inputInner:invalid {
    background-color: rgba(255, 0, 0, .2);
}

Last updated