Customization
Take advantage of the Front's past, current and future updates, by learning how to create your own content without changing the core styles of Front.
How to include a typeface?
Add or change Front typography with the following instructions.
With SASS
-
Use the
$font-family-base
attribute as our typographic base applied to the<body>
in_user-variables.scss
file to change the current font family variable with yours.$font-family-base: "Inter", sans-serif !default;
-
Add your font stylesheet into the
<head>
before all other stylesheets. Like:<!-- CSS Global Compulsory --> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap">
With css
-
Simply replace the font family
font-family
from<body>
intheme.css
tag with yours.body { font-family: "Inter", sans-serif; }
-
Add your font stylesheet into the
<head>
before all other stylesheets. Like:<!-- CSS Global Compulsory --> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap">
SASS
Utilize our source SASS files to take advantage of variables, mixins, and more.
Whenever possible, avoid modifying Front's core files. For SASS, that means creating your own stylesheet that imports Bootstrap so you can modify and extend it.
Customizing SASS
To avoid file loss, overrides of your custom styles or any other conflicts during the upgrade process, create or modify your styles with these 2 files src/assets/scss/
:
_user-variables.scss
- Variables file for customizing or overriding Bootstrap core and Front elements/components that have been tied to variables._user.scss
- Create a new style in here.
theme.css
file.
Variable defaults
Every SASS variable in Front includes the !default
flag allowing you to override the variable's default value in your own SASS without modifying either Bootstrap or Front's source code. Copy and paste variables as needed, modify their values, and remove the !default
flag. If a variable has already been assigned, then it won't be re-assigned by the default values in Front.
You will find the complete list of Front's variables in src/assets/scss/front/_variables.scss
.
Variable overrides within the same SASS file can come before or after the default variables. However, when overriding across SASS files, your overrides must come before you import Front's SASS files.
Here's an example that changes the color
of the template in the scss/_user-variables.scss
file when importing and compiling Front via npm:
// Your variable overrides
$blue: #377dff; // Primary color
Modify map
To modify an existing color in our $theme-colors
map, add the following to your custom SASS file:
$theme-colors: (
"primary": #377dff,
"danger": #ed4c78
);
Add to map
To add a new color to $theme-colors
, add the new key and value:
$theme-colors: (
"primary": #377dff,
"danger": #ed4c78
);
SASS options
Customize Front with our built-in custom variables file and easily toggle global CSS preferences with $enable-*
SASS variables.
You can find and customize these variables for key global options in Front's scss/front/_variables.scss
file.
$theme-colors: (
"primary": #377dff,
"danger": #ed4c78
);
Variable | Values | Description |
---|---|---|
$enable-accessibility |
true or false (default) |
Enables predefined accessibility styles on various components. |
$enable-shadows |
true or false (default) |
Enables predefined box-shadow styles on various components. |
$enable-rounded |
true (default) or false |
Enables predefined border-radius styles on various components. |
$enable-caret |
true or false (default) |
Enables pseudo element caret on .dropdown-toggle . |
$enable-responsive-font-sizes |
true (default) or false |
Enables responsive font sizes. |
$enable-validation-icons |
true or false (default) |
Enables background-image icons within textual inputs and some custom forms for validation states. |
颜色
Many of Front's various components and utilities are built through a series of colors defined in a SASS map. This map can be looped over in SASS to quickly generate a series of rulesets.
Theme colors
We use a subset of all Bootstrap colors to create a smaller color palette for generating color schemes, also available as SASS variables and a SASS map in Front's scss/front/_variables.scss
file.
Here's how you can use these in your SASS:
.alpha {
color: $primary;
}
// From the SASS map with Bootstrap `color()` function {
.beta {
color: color("purple");
}
颜色 utility classes are also available for setting color
and background-color
.
Grays
An expansive set of gray variables and a SASS map in scss/front/_variables.scss
for consistent shades of gray across your project.
SASS components
Many of Bootstrap's components and utilities are built with @each
loops that iterate over a SASS map. This is especially helpful for generating variants of a component by $theme-colors
and creating responsive variants for each breakpoint. As you customize these SASS maps and recompile, you'll automatically see your changes reflected in these loops.
Customizing JS
To avoid file loss, overrides of your custom styles or any other conflicts during the upgrade process, create or modify your styles with assets/js/theme-custom.js
file.