Syntax:
/* importing name and file path is /_file.scss */ @import 'file';
- Approach 1: Import multiple Sass partials
- To import multiple sass partials with @import by adding @import followed by first filename within quotes then comma(, ) then followed by second filename within quotes end with semicolon
-
/* importing name and file path is /_file1.scss and /_file2.scss */ @import 'file1', 'file2' ;
Example 1: Below example illustrates above approach.
SASS files/* _colors.scss */$primary:#00ff40;$secondary:#f44336;$tretiary:#03a9f4;$tera:#ffeb3b;$dark:#000000;$grey:#919191;$light:#dddddd;$white:#FFFFFF;/* _std.scss */html,body,ul,ol {margin:0;padding:0;}body {color:$grey;font-family:Helvetica,sans-serif;background-image:url('/img/backimg.jpg');background-repeat:no-repeat;background-attachment:fixed;background-position:center;background-size: cover;}/*_section.scss*/div{padding: {top:20px;left:10px;right:10px;bottom:20px;}h1{color: $secondary!important;align-items:center;}}/* style.scss*/@import'colors';@import'std','section';chevron_rightfilter_noneCompiled CSS file: style.css
html, body, ul, ol { margin: 0; padding: 0; } body { color: #919191; font-family: Helvetica, sans-serif; background-image: url("/img/backimg.jpg"); background-repeat: no-repeat; background-attachment: fixed; background-position: center; background-size: cover; } div { padding-top: 20px; padding-left: 10px; padding-right: 10px; padding-bottom: 20px; } div h1 { color: #f44336 !important; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } - Approach 2: Import Plain CSS
- To load Plain CSS with @import by following way:
- @import followed by path of CSS file with extension .css wrapped within double quotes.
- In case of URL path, complete URL specified within url(” “);
-
/* importing plain CSS*/ @import "mytheme.css"; @import "http://fonts.googleapis.com/css?family=Droid+Sans"; @import url("http://fonts.googleapis.com/css?family=Droid+Sans"); @import url(mytheme); @import "landscape" screen and (orientation: landscape);
Example 2:Below example illustrates above approach.
SASS file: style.scss@mixin google-font($family) {}@include google-font("Serif Sans");chevron_rightfilter_noneCompiled CSS file: style.css
@import url("http://fonts.googleapis.com/css?family=Serif Sans"); - Approach 3: Import Modules and configure Modules
- To load modules and configure modules with @import by following way:
- To make this easier.Sass also supports import-only files such as follows:
- _filename.scss is imported to import only files
filename.import.scss which as@forward "filename" as filename-*;
- In case @use this method not recommended.
- To configure modules, modules loaded through @import by defining global variables with respect to initial load of that module.
Example 3:
Below example illustrates above approach.
SASS files/*_libray.scss */$purple:Purple;$white:white;button{color:$white;border-color:$purple;background-color:$purple;padding :10px;}/* _library.import.scss */@forward'library'as lib-*;/* style.sass */$lib-color: indigo;@import"library";chevron_rightfilter_noneCompiled CSS file: style.css
button{ color: white; border-color:indigo; background-color:indigo; padding :10px; }
Reference: https://sass-lang.com/documentation/at-rules/import
Recommended Posts:
- How to use Sass Variables with CSS3 Media Queries ?
- Sass sass:list Module
- Sass sass:color Module
- Sass | sass:map module
- SASS sass:string Module
- How to see the changes in whole directory/folder containing many sass files ?
- SASS | Variables
- How to use SASS to create new set of color styles in Bootstrap 4 ?
- How to Configure Mouse Wheel Speed Across Browsers using JavaScript ?
- Broadcasting across arrays in Julia
- How to select and upload multiple files with HTML and PHP, using HTTP POST?
- How to Select Multiple Files using HTML Input Tag ?
- How to add multiple font files for the same font ?
- How to use JavaScript variables in jQuery selectors ?
- NODE_ENV Variables and How to Use Them ?
- JavaScript | Replace multiple strings with multiple other strings
- How to create optional arguments for a SASS mixin?
- Sass @function Rule
- CSS Preprocessor | SASS
- How to calculate percent minus px in SASS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

