Open In App

Bulma Mixins

Improve
Improve
Like Article
Like
Save
Share
Report

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;

  • Element Mixins: These mixins are used to create visual HTML elements.
  • CSS Mixins: These mixins are used to add CSS rules to the HTML element.
  • Direction Mixins: These mixins are used to add left or right alignment to the HTML element.
  • Form Control Mixins: These mixins are used tor buttons and form controls created in Bulma.
  • Responsive mixins: These mixins are used to define various styles for different screen sizes.

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.

HTML




<!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>


CSS




@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.

HTML




<!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>


CSS




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


Output:

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



Last Updated : 22 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads