Questions tagged [scss-mixins]

Mixins allow you to define styles that can be re-used throughout your stylesheet

One of the most important usages of mixins is to avoid using non-semantic classes like .float-left.

Mixins are defined using the @mixin at-rule, which is written

@mixin <name> { ... } or @mixin name(<arguments...>) { ... }

A mixin’s name can be any Sass identifier, and it can contain any statement other than top-level statements.

Example of mixin in SCSS:

@mixin reset-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

@mixin horizontal-list {
  @include reset-list;

  li {
    display: inline-block;
    margin: {
      left: -2px;
      right: 2em;
    }
  }
}

nav ul {
  @include horizontal-list;
}

Result in CSS:

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
nav ul li {
  display: inline-block;
  margin-left: -2px;
  margin-right: 2em;
}
655 questions
50
votes
1 answer

How to include SCSS file in HTML

I dont know how to include SCSS file in my website but I have completely developed .scss file using notepad. Please let me know how to include it in my website?
Yuvaraj
  • 549
  • 1
  • 4
  • 5
36
votes
4 answers

Tailwind CSS - Responsive breakpoints as components

How should I deal with responsive breakpoints as components in Tailwind? Without Tailwind, I used to declare breakpoints as a scss mixins: @mixin tablet-portrait { @media (min-width: 700px) { @content; } } Then: @include tablet-portrait { …
aitor
  • 2,281
  • 3
  • 22
  • 44
16
votes
6 answers

How do I use bootstrap mixins in angular-cli

I tried using a mixin in my styles.scss but it says it is not defined. I've tried: Using it in styles.scss @include media-breakpoint-up(sm) { .some-class { display: block; } } result: @include media-breakpoint-up(sm) { ^ No…
gyozo kudor
  • 6,284
  • 10
  • 53
  • 80
14
votes
2 answers

How Can I Use Multiple @include in SCSS?

I want to use multiple include in the same SCSS. For example: .section-ptb { padding-top: 130px; padding-bottom: 130px; @include desktop { padding-top: 80px; padding-bottom: 80px; } @include tablet { …
Rubel Hossain
  • 2,503
  • 2
  • 22
  • 23
14
votes
1 answer

How to set custom button text color in Bootstrap 4 and Sass?

I would like to create a new button style in Bootstrap 4 with a white (#fff) text color. Mixin button-variant automatically sets the text color based on the background color. How can I use this mixin and set the color at the same time, without…
konichiwa
  • 532
  • 1
  • 5
  • 23
10
votes
1 answer

Create new color scheme for dark-light mode in bootstrap sass

I want to create dark mode for a web site which use bootstrap. I have to add new root class which includes all boostrap colors. Here is my…
9
votes
2 answers

Bootstrap 5 + SASS error: undefined MIXIN @include _assert-ascending

I'm learning SCSS following a freecodecamp tutorial, but I keep getting the following error on the CLI for live sass: watch: Error: Undefined mixin. ╷ 320 │ @include _assert-ascending($grid-breakpoints, "$grid-breakpoints"); │…
Joe Rodriguez
  • 91
  • 1
  • 3
9
votes
2 answers

Is there a way to dynamically update scss variables using JS in react?

Problem I have two scss variables places in colors.scss file, I want to update the variable colors only from javascript based on a logic, if(day){ // update $backgroundColor to white }else{ // update $backgroundColor to black } More info: I…
Shujath
  • 846
  • 1
  • 8
  • 22
8
votes
1 answer

Does using @import more than once duplicate css?

I have an Angular CLI app and I'm using @import '~@angular/material/theming'; in the global styles.scss. I also have a component where I would like to define a css class in that component's .scss file that uses some of the Angular Material…
adam0101
  • 29,096
  • 21
  • 96
  • 174
7
votes
2 answers

Scss: @include media-breakpoint-down: Undefined mixin but I import bootstrap class

I tried to use @include media-breakpoint-up in Angular but when compile get this error Bootstrap 5.1.13 Angular CLI: 10.2.4 Node: 14.17.2 OS: win32 x64 Angular: 10.2.5 ERROR in Module build failed (from…
apnnux
  • 361
  • 4
  • 11
7
votes
1 answer

How to use SCSS mixins with angular 7

I am getting this error in my angular project. @include for-desktop-up {...." No mixin named for-desktop-up" My code in the styles.scss is @mixin for-desktop-up { @media (min-width: 1024px) { @content; } } My code in a stylesheet of a…
YulePale
  • 6,688
  • 16
  • 46
  • 95
7
votes
1 answer

Why we are using SASS, even we are using SCSS?

I am working already by SCSS in my projects but I'm still confused. Why we are using SASS even we have SCSS, and can we use SASS and SCSS at the same projects, it will work at the same projects?
user10991969
6
votes
2 answers

SCSS Theming with Dynamic Variables

Hi All! I'm currently working on a theming feature for a CSS Framework and have run into some issues that I'm hoping you might be able to help out with. I have created a SASS Map called $themes, which contains colors for different themes. I…
joshwcorbett
  • 389
  • 5
  • 18
5
votes
2 answers

Tailwindcss does not work in Vue.js when all process of intergration has been done?

i installed tailwindcss into a vuejs SPA did all the setup create a assets/css/tailwind.css and added the necessary base styles imported it in the main.js file create a postcss.config.js file and copied the required configuration from the official…
Nadeem Khan
  • 127
  • 2
  • 11
5
votes
1 answer

What does "use this SASS mixin" mean in the context of Material Design Components?

I am using the Material Design Components for Web library. I have a tab component that I'd like to change the underline-color of. The instructions say To customize the tab indicator, use the following mixins. Then it gives a table. For underline…
Caleb Jay
  • 2,159
  • 3
  • 32
  • 66
1
2 3
43 44