Open In App

Bulma Mixins

In this article, we will know about Bulma mixins. Bulma mixins help the users create CSS code that can be reused throughout the website.

Bulma uses Sass mixins to create the CSS output and they are mainly used within the context of the Bulma framework. Bulma has various different types of mixins as given below;



For using mixins, there is no specific class given by Bulma rather we create our own classes and style them using SASS mixins.

Syntax:



.bulma-mixin {
    @include mixin();
}

Note: You must know the implementation of SASS mixins for the below examples. Please see the pre-requisite given on the link and then implement the below code.

Example 1: Below example illustrates the Bulma Mixins in a font awesome icon.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GFG</title>
    <link rel="stylesheet" href=
  
    <link rel="stylesheet" href="demo.css">
</head>
  
<body>
    <div class="container content ">
        <h1 class="title has-text-success">GeeksforGeeks</h1>
        <h1 class="subtitle">Bulma Mixins</h1>
  
        <span class="bulma-fa-mixin">
            <i class="fab fa-github"></i>
        </span>
  
    </div>
</body>
  
</html>




@mixin fa($size, $dimensions) {
    font-size: $size;
    color: white;
    padding: 10px;
    width: $dimensions;
    background-color: black;
}
  
.bulma-fa-mixin {
    @include fa(4rem, 5rem);
}

Output:

Example 2: This example illustrates the Bulma clearfix mixin.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
  
    <link rel="stylesheet" href=
    </script>
    <link rel="stylesheet" href="demo.css">
</head>
  
<body>
    <div class="container content ">
        <h1 class="title has-text-success">GeeksforGeeks</h1>
        <h1 class="subtitle">Bulma Mixins</h1>
  
        <div class="container">
            <div class="bulma-clearfix-mixin has-background-warning p-4">
                <img height="80" width="80" 
                     style="float:right; border-radius:5rem;"
                    src=
                <h1 class="subtitle" style="font-weight:bold;">
                    Welcome to GeeksforGeeks
                </h1>
                  
<p>All in one place for computer science geeks!</p>
  
            </div>
        </div>
    </div>
</body>
  
</html>




@mixin clearfix() {
    clear: both;
    content: " ";
    display: table;
}
  
.bulma-clearfix-mixin {
    @include clearfix();
}

Output:

Reference: https://bulma.io/documentation/utilities/mixins/


Article Tags :