zurb-foundationzurb-foundation-6

Foundation 6 switches don't work?


In the following very basic example the switch works and is styled properly. If I merely change the foundation.css version from 5.5.2 to 6.0.5 the toggle style is lost. Why don't switches work in Foundation 6.0??? Again, just change the style sheet to "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.5/css/foundation.css" and it stops working.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Foundation Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.css">

  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.5/js/foundation.min.js"></script></head>
<body>

<div style="padding:20px;">
  <div class="switch large">
    <input id="mySwitch1" type="checkbox">
    <label for="mySwitch1"></label>
  </div> 
</div>

</body>
</html>

Solution

  • Foundation has changed its naming scheme slightly in version 6.0, so you would need to update your HTML to match that. See the documentation here:

    http://foundation.zurb.com/sites/docs/switch.html

        <div class="switch large">
            <input class="switch-input" id="largeSwitch" type="checkbox" name="exampleSwitch">
            <label class="switch-paddle" for="largeSwitch">
                <span class="show-for-sr">Show Large Elephants</span>
            </label>
        </div>