Styling a section
Use FastStore utilities and custom Sass mixins to create reusable styles for storefront sections.
3 min read
FastStore sections support Sass mixins, which let you reuse style groups. This guide shows how to style a custom section with FastStore utility mixins and how to share a custom mixin across sections.
Before you begin
- Create a custom section by following the Creating a new section guide.
- Use a CSS Module file with the
.module.scssextension for the section styles.
Using FastStore mixins in a section
The FastStore utility stylesheet provides mixins for layout, spacing, responsive breakpoints, text truncation, and focus states. Import this stylesheet with the Sass
@use rule in every SCSS file that uses its mixins.The following example styles a
PromoBanner section.-
Create
src/components/PromoBanner/section.module.scssand import the FastStore utilities. Theas uclause assigns them theunamespace, which is used in each@include.In this example:layout-contentlimits the section to the store content width and centers it.media(">=tablet")applies styles at thetabletbreakpoint and above.truncate-title(2)limits the title to two lines.- FastStore global tokens provide consistent spacing, color, and typography values.
@layer componentsplaces the styles in the FastStore component layer so they follow the expected cascade order.
-
Import the stylesheet in the section component and apply its classes to the corresponding elements.
-
Run your FastStore project locally and open a page that contains the section. The section uses a single-column layout on smaller screens and changes to two columns at the
tabletbreakpoint.

Creating a reusable mixin
For styles shared by multiple custom sections, create a Sass module in your project and explicitly load it in each section stylesheet.
-
Create
src/styles/_section-mixins.scss: -
Import the module into the section stylesheet and include the mixin:
The leading underscore in
_section-mixins.scss marks the file as a Sass partial. Omit the underscore and the file extension in the @use path.Available FastStore utilities
The utility stylesheet includes:
| Category | Utilities |
|---|---|
| Layout and spacing | layout-content, layout-content-full, layout-colored, and section-divisor |
| Responsive styles | media, with the phone, phonemid, tablet, notebook, and desktop breakpoints |
| Text | truncate-title |
| Focus states | input-focus-ring, focus-ring, and focus-ring-visible |
| Unit conversion | rem function |
All FastStore utilities use a namespace. For example:
_10@use "@faststore/ui/src/styles/base/utilities" as u;_10_10.example {_10 font-size: u.rem(18px);_10_10 @include u.media("<notebook") {_10 @include u.layout-content;_10 }_10}
Best practices
- Utility mixins are not global in FastStore v4. Each SCSS file that uses them must load the utility stylesheet with
@use. - A
src/styles/custom-mixins.scssfile isn't automatically loaded into section styles. Import project mixins explicitly in every file where you use them. - Sass mixins run when the storefront CSS is built. They can't be selected or configured by content editors in Headless CMS. To make a style configurable in the CMS, expose a section property and map its value to a class or data attribute in the component.
- Use design tokens when you only need to change a component's colors, spacing, typography, or other theme values. Use mixins for reusable groups of style declarations.