Open In App

Bulma Button Variables

Bulma is a free, and open-source CSS framework based on flexbox. It is component rich, compatible, and well documented. It is highly responsive in nature. It uses classes to implement its design.
Buttons in Bulma CSS have classic designs in different colors, sizes, and states which makes it interactive.

Variable Used:



Example 1: This example creates colored buttons using Bulma and modifies that button using variables.




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
"width=device-width, initial-scale=1">
    <title>Hello Bulma!</title>
    <link rel="stylesheet" href=
    <link rel="stylesheet" href="style.css">       
     <!-- font-awesome cdn -->
    <script src=
    </script>       
</head>
 
<style>
    button{
        margin-left:420px;
    }
</style>
 
<body>
    <center>   
        <h1 class="title has-text-centered has-text-success">
            GeeksforGeeks
        </h1>
        <h3 class="subtitle has-text-centered">
            A computer science portal for geeks.
        </h3>
        <div class='container has-text-centered'>
            <div class='buttons has-text-success'>
                <button class="but">
                    GeeksforGeeks
                </button>           
            </div>
        </div>
    </center>
</body>
</html>

SCSS Code:



$button-background-color:green;
.but{
  background-color:$button-background-color;
  }

Compiled CSS Code:

.but {
 background-color: green; }

Output:

 

Example 2: This example creates colored buttons using Bulma and modifies that button using variables.




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
"width=device-width, initial-scale=1">
     
    <link rel="stylesheet" href=
    <link rel="stylesheet" href="style.css">       
     <!-- font-awesome cdn -->
    <script src=
    </script>   
</head>
<style>
 button{
    margin-left: 420px;
 }
</style>
<body>
    <center>   
        <h1 class="title has-text-centered has-text-success">
            GeeksforGeeks
        </h1>
        <h3 class="subtitle has-text-centered">
            A computer science portal for geeks.
        </h3>
 
        <div class='container has-text-centered'>
            <div class='buttons'>
                <button class="but">
                    GeeksforGeeks
                </button>               
            </div>
        </div>       
    </center>
</body>
</html>

SCSS Code:

$button-color:green;
.but{
  color:$button-color;
}

Compiled CSS Code:

.but {
 color: green; 
}

Output:

 

Reference: https://bulma.io/documentation/elements/button/


Article Tags :