Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Vikram Ramanujam
Vikram Ramanujam

Posted on • Edited on

     

Completely configurable, flexible, re-usable CSS-only checkbox toggles

Configurable using CSS Custom properties!. Found a lot of great examples of toggles around the web, but all of them had some form of hard-coded values. Check out the code. Uses line-height and follows the natural sizing given to it. Feel free to steal :)

<inputclass="switch"id="switch-55"type="checkbox"/><labelfor="switch-55"style="    --switch-width: 3rem; /* optional properties */    --switch-knob-size: .8rem;  ">Toggle</label>
/* the following properties are configurable by simply overriding them: */:{--switch-background:silver;--switch-background-active:mediumseagreen;--switch-width:3ch;--switch-knob-size:calc(var(--switch-width)/3);--switch-knob-offset:calc(50%-(var(--switch-knob-size)/2));--switch-knob-color:white;--switch-transition-duration:0.3s;}

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Styled human component. Web slinger. React / web components lover.
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp