Importing FastStore UI component styles
If you are using a FastStore UI component and want to apply its styles to your FastStore project, follow the steps below.
There are two different scenarios on how to import FastStore UI component styles:
- Overriding a component: For this use case, we will override the
ProductTitle
component within theProductDetails
section. - Creating a new section: For this use case, we will create a new section in the CMS called
OurStore
.
Before you begin
Ensure you have a basic understanding of overrides
Refer to the Overriding components and props and Creating a new section guides for more information. In this guide, we will use the
ProductTitle
component and OurStores
section.Using CSS modules
We recommend using CSS
Modules to style your new component.
Importing styles when overriding a component
For this scenario, we will use as an example the override of the ProductTitle component within the
ProductDetails
section.-
Open your FastStore project, navigate to the
components
folder, and create thecustomProductTitle.module.scss
file. This file is responsible for importing the FastStore UI component style. -
Add the following code to the
customProductTitle.module.scss
file.
This code imports the Tag styles to the custom component that you are creating.
-
Import the styles in the
CustomProductTitle.tsx
file and add aclassName
to thesection
-
Run
yarn dev
in the terminal and open the local development server to see the changes. You should see a result similar to the image below:
Importing styles when creating a new section
To follow this guide, we recommend creating the
OurStores
section, which we will use as an example.With the section on the page, add some styles to it by opening the
components
folder and creating the ourStores.module.scss
file. This file will import the FastStore UI components styles.
Add the following code to the ourStores.module.scss
file:This code imports the Button and SelectField styles to the custom component that you are creating.
You also need to import the
Select
component styles since SelectField
inherits them.-
Now, import this stylesheet to
OurStores.tsx
file and apply it.
You should be able to see something like the following:
-
Let's add more styles to it. You can customize it using the design tokens and component's data attributes.
After applying these additional styles, you should be able to see this final look: