Open In App

Foundation CSS Switch Disabled

Last Updated : 22 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on SaaS-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices. Switch, in general, gives the user an option to select one of the two possibilities present. So a basic switch is one in which we can toggle it on or off. In Foundation CSS switch is nothing but a check-box markup which we use to create this style. Switch Disabled means we can disable the functionality of a switch by using the appropriate class required.

Foundation CSS Switch Disabled Classes:

  • switch: This class is given to the element which has to be made the switch.
  • switch-input: This class is given to the input element whose type must be a checkbox and this is responsible for toggling the switch on and off.
  • disabled: This class fixes a switch into a fixed or static position. This can be accomplished by setting this on the switch input.

Syntax:

<div class="switch">
     <input class="switch-input" id="xy" disabled type="checkbox">
     <label class="switch-paddle" for="xy">
           <span class="show-for-sr">...</span>
     </label>
</div>

Example 1: This is a basic example illustrating Switch Disabled made using Foundation CSS.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <title>Foundation CSS Switch Disabled</title>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
"//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.min.css" />
    <!-- Compressed JavaScript -->
    <script src=
</script>
    <script src=
</script>
</head>
  
<body>
    <center>
        <h1 style="color: green;">GeeksforGeeks</h1>
        <strong>Foundation CSS Switch Disabled</strong>
    </center>
    <div style="margin: 3% 42%;">
          
<p>CheckedDisabledSwitch</p>
  
        <div class="switch">
            <input class="switch-input" disabled checked="checked" 
            id="exampleCheckedDisabledSwitch" type="checkbox"
                name="exampleCheckedDisabledSwitch">
            <label class="switch-paddle" for="exampleCheckedDisabledSwitch">
                <span class="show-for-sr">Can't Touch This Checked</span>
            </label>
        </div>
          
<p>UncheckedDisabledSwitch</p>
  
        <div class="switch">
            <input class="switch-input" disabled 
            id="exampleUncheckedDisabledSwitch" 
            type="checkbox"
            name="exampleUncheckedDisabledSwitch">
            <label class="switch-paddle" 
            for="exampleUncheckedDisabledSwitch">
                <span class="show-for-sr">
                      Can't Touch This Unchecked
                  </span>
            </label>
        </div>
    </div>
    <script>
        $(document).foundation();
    </script>
</body>
  
</html>


Output:

Example 2: This is a basic example illustrating Different Sizes of Switch Disabled made using Foundation CSS.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <title>Foundation CSS Switch Disabled</title>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
"//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.min.css" />
    <!-- Compressed JavaScript -->
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
          
        <strong>Foundation CSS Switch Disabled</strong>
          
<p>Different sizes of disabled switches</p>
  
    </center>
      
    <div style="margin: 5% 45%;">
        <div class="switch tiny">
            <input class="switch-input"
                 disabled checked="checked" 
                id="exampleCheckedDisabledSwitch" 
                type="checkbox"
                name="exampleCheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleCheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Checked
                </span>
            </label>
        </div>
        <div class="switch tiny">
            <input class="switch-input" 
                disabled id="exampleUncheckedDisabledSwitch"
                type="checkbox"
                name="exampleUncheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleUncheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Unchecked
                </span>
            </label>
        </div>
        <div class="switch small">
            <input class="switch-input" 
                disabled checked="checked" 
                id="exampleCheckedDisabledSwitch" 
                type="checkbox"
                name="exampleCheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleCheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Checked
                </span>
            </label>
        </div>
        <div class="switch small">
            <input class="switch-input" 
                disabled id="exampleUncheckedDisabledSwitch" 
                type="checkbox"
                name="exampleUncheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleUncheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Unchecked
                </span>
            </label>
        </div>
        <div class="switch medium">
            <input class="switch-input" 
                disabled checked="checked" 
                id="exampleCheckedDisabledSwitch" 
                type="checkbox"
                name="exampleCheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleCheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Checked
                </span>
            </label>
        </div>
        <div class="switch medium">
            <input class="switch-input" 
                disabled id="exampleUncheckedDisabledSwitch" 
                type="checkbox"
                name="exampleUncheckedDisabledSwitch">
            <label class="switch-paddle" 
                for="exampleUncheckedDisabledSwitch">
                <span class="show-for-sr">
                    Can't Touch This Unchecked
                </span>
            </label>
        </div>
    </div>
      
    <script>
        $(document).foundation();
    </script>
</body>
  
</html>


Output:

Reference: https://get.foundation/sites/docs/switch.html



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads