Customization
If you read about development tools you will find out that you can use Sass, so it is possible to customize the basic styles of FlatifyCSS.
Sass
The first level of customization happens in the _config.scss file, in this file variables for colors, fonts, and other basic configs are defined, for example, by changing the $CSS_VAR_PFX variable all generated CSS variables will be prefixed with this value.
Take a look at the config file to see how it works. Variables in this file are categorized by their type, general, design, colors, motion, typography, and icons. So you can change their value and see how the changes affect the generated CSS and frontend.
You do not need to edit the package files for this. All variables use !default, so set your own values when you load FlatifyCSS in your Sass file:
@use "flatifycss/scss/flatify" with (
$ACCENT_COLOR: #8e44ad,
$BORDER_RADIUS: 0.5em,
$PRIMARY_FONT_FAMILY: ("Inter", sans-serif)
);
Or the older way, which works too:
$ACCENT_COLOR: #8e44ad;
$BORDER_RADIUS: 0.5em;
@import "flatifycss/scss/flatify";
For example here is the list of variables that are defined for z-index:
| Variable | Default |
|---|---|
$ZINDEX_DROPDOWN | 1000 |
$ZINDEX_STICKY | 1010 |
$ZINDEX_FIXED | 1020 |
$ZINDEX_FIREWORKS | 1025 |
$ZINDEX_BACKDROP | 1030 |
$ZINDEX_MODAL_BACKDROP | 1030 |
$ZINDEX_MODAL | 1040 |
$ZINDEX_POPOVER | 1060 |
$ZINDEX_TOAST | 1100 |
You can change their value based on the number of the z-index you use in your project.
General and design
| Variable | Default | What it does |
|---|---|---|
$CSS_VAR_PFX | flatify__ | Prefix of every generated CSS variable |
$CENTERED_CONTAINERS | true | Centers containers with auto margins |
$RESPONSIVE_BREAKPOINTS | (xs: 575.98px, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px) | See the responsive page, change the values but keep the names |
$BORDER_WIDTH | max(2px, 0.18em) | Border width of components |
$BORDER_RADIUS | 1em | Default roundness of components |
$BORDER_RADIUS_LIST | Generates the roundness setters | |
$WIDTH_LIST, $HEIGHT_LIST | Generate the width and height setters | |
$OPACITY_LIST | (0, 10, 20, ..., 100) | Generates the opacity setters |
$HOVER_BRIGHTNESS | 95% | How much elements get darker on hover |
$BACKDROP_OPACITY | 0.5 | Opacity of the backdrop layer |
$LINK_DECORATION | none | Link text-decoration |
$LINK_DECORATION_HOVER | underline 0.125em currentColor | Link text-decoration on hover |
$LINK_DECORATION_FOCUS | none | Link text-decoration on focus |
Colors
| Variable | Default | What it does |
|---|---|---|
$BG_COLOR | #ffffff | Page background |
$BG_COLOR_2, $BG_COLOR_3, $BG_COLOR_4 | #f1f4f7, #ced9e3, #809cb6 | Darker backgrounds and borders |
$TXT_COLOR | #2e4051 | Text color, its light, dark and inverted versions are made from it |
$BLUE, $GREEN, $YELLOW, $ORANGE, $RED, $PINK, $PURPLE | Palette colors, each one also has _LIGHT, _DARK and _DARKER versions | |
$ACCENT_COLOR, $SUCCESS_COLOR, $INFO_COLOR, $WARNING_COLOR, $DANGER_COLOR | blue, green, blue, orange, red | State colors |
$LIGHT_COLOR, $DARK_COLOR | background and text colors | Used by .style-light and .style-dark |
$HEADING_COLOR | currentColor | Headings color |
$LINK_COLOR, $LINK_COLOR_HOVER, $LINK_COLOR_FOCUS | accent, accent light, accent dark | Link colors |
$TAP_HIGHLIGHT_COLOR | transparent | -webkit-tap-highlight-color on mobile |
The $PALETTE map is built from these variables, do not edit it directly. All hex values are on the colors page.
Motion
| Variable | Default | What it does |
|---|---|---|
$SUPPORT_SMOOTH_SCROLL | true | Smooth scrolling for users who do not prefer reduced motion |
$SIMPLE_TRANSITION | 0.15s ease-in-out | Most hover and focus transitions |
$LONG_TRANSITION | 1s ease-in-out | Slow transitions |
$BOUNCING_TRANSITION | 0.35s cubic-bezier(0.59, -0.39, 0.36, 1.38) | Transitions with a little bounce |
$ACCORDION_SHOW_ANIMATION_DURATION / $ACCORDION_HIDE_ANIMATION_DURATION | 300ms / 200ms | Accordion animations |
$ALERT_SHOW_ANIMATION_DURATION / $ALERT_HIDE_ANIMATION_DURATION | 200ms / 300ms | Alert animations |
$DROPDOWN_SHOW_ANIMATION_DURATION / $DROPDOWN_HIDE_ANIMATION_DURATION | 300ms / 200ms | Dropdown animations |
$MODAL_SHOW_ANIMATION_DURATION / $MODAL_HIDE_ANIMATION_DURATION | 350ms / 250ms | Modal animations |
$SUBMENU_SHOW_ANIMATION_DURATION / $SUBMENU_SHOW_ANIMATION_DELAY | 350ms / 200ms | Submenus in the navigation bar |
$TAB_SHOW_ANIMATION_DURATION / $TAB_HIDE_ANIMATION_DURATION | 300ms / 200ms | Tabs animations |
$TOAST_SHOW_ANIMATION_DURATION / $TOAST_HIDE_ANIMATION_DURATION | 300ms / 200ms | Toast animations |
Typography and icons
Typography variables are listed on the typography page.
Icons are SVG data URLs, you can replace any of them with your own: $ARROW_DOWN_ICON, $BLOCKQUOTE_ICON, $CLOSE_ICON, $EYE_ICON, $SEARCH_ICON and $SELECT_ICON. Each one is also a CSS variable, for example --flatify__close-icon.
CSS
The next level after customization with Sass is CSS variables. These variables get their values from Sass variables, so if you just want to work with compiled CSS, it is the best choice to change them. The benefits of CSS variables are they can be customized modularly, which means you can have different components with different colors, fonts, etc, just by changing the value of the variables.
Default CSS variables are defined as :root, most of them are defined in the _root.scss file, the rest are defined inside each file which is a separate component, for example, table CSS variables are inside the _table.scss file.
The example of customization each component is provided in the component's documentation page. For example check the table component customization guide.
JavaScript
There is a JSON file inside the /js folder called config.json, which provides you the most important configuration options for the JavaScript code, for example, you can disable logging errors in the console when something goes wrong. All options are listed on the JavaScript page.