Bulma – Checkbox and Radio

Bulma checkbox and radio

In this guide, we will discuss Checkbox and radio in Bulma.

Description

The checkboxes (select multiple options from a given list) and radio buttons (select only one option from a given list) can be used when you want users to choose from a list of preset options. Use the checkbox and radio classes in the input tag to keep up the cross-browser compatibility and the user experience.

Checkbox

The below example shows creation of checkbox by using checkbox class in Bulma −

<!DOCTYPE html>
<html>
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <title>Bulma Forms Example</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
      <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
   </head>
   
   <body>
      <section class = "section">
         <div class = "container">
            <span class = "title">
               Checkbox
            </span>
            <br>
            <br>
            
            <div class = "checkbox">
               <label class = "is-size-5">Fruits</label>
               <br>
               <label class = "checkbox">
                  <input type = "checkbox">
                  Orange
               </label>
               
               <label class = "checkbox">
                  <input type = "checkbox">
                  Apple
               </label>
               
               <label class = "checkbox">
                  <input type = "checkbox">
                  Grapes
               </label>
               
               <label class = "checkbox">
                  <input type = "checkbox">
                  Mango
               </label>
            </div>
            <br>
            <br>
            
            <label class = "is-size-5">Disabled Checkbox</label>
            <br>
            <label class = "checkbox" disabled>
               <input type = "checkbox" disabled>
               Orange
            </label>
            
         </div>
      </section>
      
   </body>
</html>

Radio button

The below example shows creation of radio button (using radio class in label) in Bulma −

<!DOCTYPE html>
<html>
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <title>Bulma Forms Example</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
      <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
   </head>
   <body>
      <section class = "section">
         <div class = "container">
            <span class = "title">
               Radio Button
            </span>
            <br>
            <br>
            
            <div class = "checkbox">
               <label class = "is-size-5">Fruits</label>
               <br>
               
               <label class = "radio">
                  <input type = "radio" name = "fruitdemo">
                  Orange
               </label>
               <label class = "radio">
                  <input type = "radio" name = "fruitdemo">
                  Apple
               </label>
            </div>
            <br>
            <br>
            
            <label class = "is-size-5">Disabled Radio Button</label>
            <br>
            
            <label class = "radio">
               <input type = "radio" name = "fruitdemo">
               Orange
            </label>
            <label class = "radio" disabled>
               <input type = "radio" name = "fruitdemo" disabled>
               Apple
            </label>
            <br>
            <br>
            
            <label class = "is-size-5">Using checked HTML attribute</label>
            <br>
            
            <label class = "radio">
               <input type = "radio" name = "fruitdemo" checked>
               Orange
            </label>
            <label class = "radio">
               <input type = "radio" name = "fruitdemo">
               Apple
            </label>
            
         </div>
      </section>
      
   </body>
</html>

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply