1.0.8 • Published 4 years ago

segmented-control-css v1.0.8

Weekly downloads
30
License
MIT
Repository
github
Last release
4 years ago

Create IOS Style radio buttons (segmented controls) without any JavaScript code.

Official demo

Table of Contents

Installation

npm i segmented-control-css
yarn add segmented-control-css

Then add the segmented-control.min.css file to your <head>. The file is located in the dist folder.

<link
  rel="stylesheet"
  href="[path-to-segmented-control-css]/dist/segmented-control.min.css"
/>

You can also use the unpkg CDN.

<link
  rel="stylesheet"
  href="https://unpkg.com/segmented-control-css/dist/segmented-control.min.css"
/>

Usage

To make Segmented Control CSS work properly:

  • All options are grouped inside an .segmented-control container.
  • Each option should have:
    • A .segmented-control-btn wrapper.
    • An <input type="radio"> with an unique id.
    • A <label> with a for attribute

⚠️ Each .segmented-control-btn needs an input with an id and a label just behind. The "for" attribute of the label needs to be the same as the id of the input. ⚠️

Example

<form>
  <div class="segmented-control">
    <div class="segmented-control-btn">
      <input type="radio" id="react" name="frameworkJs" value="react" checked />
      <label for="react">React</label>
    </div>
    <div class="segmented-control-btn">
      <input type="radio" id="angular" name="frameworkJs" value="angular" />
      <label for="angular">Angular</label>
    </div>
    <div class="segmented-control-btn">
      <input type="radio" id="vue" name="frameworkJs" value="vue" />
      <label for="vue">Vue</label>
    </div>
  </div>
</form>

Colors

To change the color of the segmented controls add the class .sc-[colorClass].

<div class="segmented-control sc-red">
  <div class="segmented-control-btn">
    <input type="radio" id="react" name="frameworkJs" value="react" checked />
    <label for="react">React</label>
  </div>
</div>
Color nameHEX codeClass
default#7768ffsc-default
red#f44335sc-red
pink#e81e61sc-pink
purple#9b26afsc-purple
deep purple#663ab6sc-deep-purple
indigo#3e50b4sc-indigo
blue#2095f2sc-blue
light blue#04a8f3sc-light-blue
cyan#00bbd3sc-cyan
teal#009587sc-teal
green#4bad4fsc-green
light green#8ac249sc-light-green
lime#ccdb38sc-lime
yellow#feea39sc-yellow
amber#fec007sc-amber
orange#fe9700sc-orange
deep orange#fe5623sc-deep-orange
brown#785447sc-brown
grey#9d9d9dsc-grey
blue grey#5f7c89sc-blue-grey

Animations

To change the animation of the segmented controls use the class .sc-[animationClass].

<div class="segmented-control sc-zoom">
  <div class="segmented-control-btn">
    <input type="radio" id="react" name="frameworkJs" value="react" checked />
    <label for="react">React</label>
  </div>
</div>
Nameclass
Fadesc-fade
Slidesc-slide
Zoomsc-zoom

Border radius

Nameclass
Roundedsc-rounded
Roundsc-round

Support

Please open an issue for support.

Author

Basile Bong

License

MIT

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago