HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<script src="https://kit.fontawesome.com/aecf18c460.js" crossorigin="anonymous"></script>
<a class="link" href="https://twitter.com/thisisfjolt" target="_top">Follow on Twitter</a>
<a class="link" href="https://fjolt.com/article/css-checkboxes" target="_top">Read the Article</a>
<h1>The List:</h1>
<div id="colors">
<div data-color="purple" data-main-color="#9100e8" data-box-shadow-tint="#9100e8cc" data-light-highlight="#d7c6ff"></div>
<div data-color="blue" data-main-color="#0074e8" data-box-shadow-tint="#0074e8cc" data-light-highlight="#c6e2ff"></div>
<div data-color="green" data-main-color="#20b951" data-box-shadow-tint="#20b951cc" data-light-highlight="#c6ffea"></div>
<div data-color="red" data-main-color="#de4947" data-box-shadow-tint="#de4947cc" data-light-highlight="#ffc6c6"></div>
<div data-color="orange" data-main-color="#dc7d17" data-box-shadow-tint="#dc7d17cc" data-light-highlight="#ffd6c6"></div>
</div>
<div class="list">
<div class="list-item">
<span class="checkbox-container f1 light" data-value="">
<input type="hidden" id="checkbox-f1-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f1" checked />
<label for="checkbox-f1" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
🎩 The old fashioned
</span>
</div>
<div class="list-item">
<span class="checkbox-container f10 light" data-value="">
<input type="hidden" id="checkbox-f10-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f10" checked />
<svg id="svgElement" width="3em" height="3em" viewBox="115 140 70 70">
<path fill="none" stroke-linecap="round" class="path" stroke="#000" stroke-width="4" d="M173 196 L172 196.33333333333334 L169.8 197.2 L164.71428571428572 197.71428571428572 L161.5 197.875 L156.125 198 L150 197.625 L143.5 196.75 L136.75 195.125 L130.875 192.75 L125.75 189.875 L121.875 186.25 L119.125 181.875 L118.125 176.875 L118.625 171.875 L120.375 167 L123.25 162.5 L127.125 158.625 L131.875 155.25 L137.5 152.625 L143.5 151.125 L149.5 151.125 L155.5 152.375 L161.25 154.5 L166.5 157.5 L171 161.125 L174.75 165.375 L177.625 170.25 L180 175.125 L181.375 179.625 L181.875 183.625 L181.5 187.25 L180.75 190.375 L179.5 193 L178 195 L176.375 196.375 L174.75 197.375 L173.375 198.125 L172 198.83333333333334 L171 199 L170.5 199"></path>
</svg>
<label for="checkbox-f10" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
Circle with pencil
</span>
</div>
<div class="list-item">
<span class="checkbox-container f2 light" data-value="">
<input type="hidden" id="checkbox-f2-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f2" checked />
<label for="checkbox-f2" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
The Slider
</span>
</div>
<div class="list-item">
<span class="checkbox-container f3 light" data-value="">
<input type="hidden" id="checkbox-f3-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f3" />
<span class="halfway alt-selection" data-value="0.5"></span>
<label for="checkbox-f3" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
I'm only halfway done
</span>
</div>
<div class="list-item dark">
<span class="checkbox-container f4 light" data-value="">
<input type="hidden" id="checkbox-f4-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f4" />
<label for="checkbox-f4" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
☄️ Slide a little more
</span>
</div>
<div class="list-item">
<span class="checkbox-container f5 light" data-value="">
<input type="hidden" id="checkbox-f5-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f5" checked />
<label for="checkbox-f5" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
⭕️ The circle
</span>
</div>
<div class="list-item">
<span class="checkbox-container f6 light" data-value="">
<input type="hidden" id="checkbox-f6-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f6" checked />
<label for="checkbox-f6" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
🎯 The target
</span>
</div>
<div class="list-item">
<span class="checkbox-container f7 light" data-value="">
<input type="hidden" id="checkbox-f7-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f7" />
<span class="noway alt-selection" data-value="0"></span>
<span class="thirdway alt-selection" data-value="0.33"></span>
<span class="threethirdway alt-selection" data-value="0.66"></span>
<span class="fullway alt-selection" data-value="1"></span>
<label for="checkbox-f7" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
4 Options, for 4 things
</span>
</div>
<div class="list-item">
<span class="checkbox-container f8 light" data-value="">
<input type="hidden" id="checkbox-f8-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f8" />
<label for="checkbox-f8" class="pseudo-checkbox">
I Agree!
</label>
</span>
<span class="list-item-text">
👩💼 The "I Agree to Terms and Conditions"
</span>
</div>
<div class="list-item">
<span class="checkbox-container f9 light" data-value="">
<input type="hidden" id="checkbox-f9-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f9" checked />
<label for="checkbox-f9" class="pseudo-checkbox">
I Agree!
</label>
</span>
<span class="list-item-text">
👩 I Agree but differently
</span>
</div>
<div class="list-item">
<span class="checkbox-container f11 light" data-value="">
<input type="hidden" id="checkbox-f11-value" class="hidden-value" checked />
<input type="checkbox" id="checkbox-f11" checked />
<svg id="svgElement1" width="1em" height="1em" viewBox="440 170 70 70">
<path fill="none" stroke-linecap="round" class="path" stroke="#fff" stroke-width="7" d="M452 202 L452 202.33333333333334 L452 204.2 L452.14285714285717 206.28571428571428 L452.25 207.375 L452.625 209.375 L453 211.625 L453.5 214 L454 216 L454.625 218.25 L455.25 220.25 L455.75 222 L456.375 223.625 L456.75 224.875 L457.25 226 L457.625 227 L458 227.875 L458.375 228.5 L458.75 229.125 L459.125 229.625 L459.375 230 L459.75 230.375 L460 230.75 L460.25 231 L460.5 231.25 L460.625 231.5 L460.875 231.5 L461.125 231.375 L461.5 231 L461.875 230.125 L462.375 228.875 L463 227.125 L464.125 224.625 L465.625 221.5 L467.125 218.25 L469.125 214.375 L471.25 210.375 L473.625 206.375 L476.125 202.125 L478.75 198 L481 194.25 L483 191 L485 187.75 L486.625 185.125 L488.125 182.875 L489.25 181 L490.125 179.625 L490.875 178.625 L491.6666666666667 177.66666666666666 L492.25 177.25 L492.5 177"></path>
</svg>
<label for="checkbox-f11" class="pseudo-checkbox"></label>
</span>
<span class="list-item-text">
🤷♂️ The handwritten tick
</span>
</div>
</div>
:root {
--main-color: #0074e8;
--box-shadow-tint: #0074e8cc;
--light-highlight: #c6e2ff;
}
html {
font-size: 24px;
}
body {
margin: 2em;
font-family: 'Source Sans Pro', sans-serif;
}
#colors {
position: fixed;
right: 2em;
top: 7em;
width: 5em;
}
#colors > div {
width: 1em;
height: 1em;
float: right;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin: 0 0em 1em 0.5em;
cursor: pointer;
border-radius: 100px;
transition: all 0.1s ease-out;
}
#colors > div:hover {
box-shadow: inset 0 0 0 100px rgba(0,0,0,0.2);
}
[data-color="purple"] {background: #9100e8;}
[data-color="blue"] { background: #0074e8; }
[data-color="green"] {background: #20b951;}
[data-color="red"] {background: #de4947;}
[data-color="orange"] {background: #dc7d17;}
a.link {
font-size: 0.75em;
background: var(--main-color);
padding: 0.5em 1em;
border-radius: 100px;
transition: all 0.1s ease-out;
color: white;
position: fixed;
top: 2em;
right: 2.5em;
text-decoration: none;
display: block;
}
a.link + .link {
top: 4rem;
}
a.link:hover {
box-shadow: inset 0 0 0 100px rgba(0,0,0,0.3);
}
[type="checkbox"] {
position: absolute;
height: 100%;
width: 100%;
margin: 0;
top: 0;
right: 999999px;
padding: 0;
}
h1 { margin: 0; }
.checkbox-container {
display: inline-block;
position: relative;
}
.list { padding: 1em 0; }
.list-item {
height: 1.5em;
border-bottom: 1px solid rgb(52 69 69 / 8%);
padding: 0.75em 0;
white-space: nowrap;
}
.list-item-text {
height: 1.5em;
display: inline-block;
vertical-align: top;
font-size: 1.1167em;
line-height: 1.5em;
margin: 0 1em;
color: #333;
font-weight: 600;
}
.dark {
background: #262b31;
border-bottom: none;
padding: 1em;
width: calc(100% + 5em);
height: 3.5em;
box-sizing: border-box;
margin: 0 0 0 -3em;
padding: 1em 3em;
}
.dark .list-item-text {
color: white;
}
/* Some default values */
.pseudo-checkbox {
width: 1.5em;
height: 1.5em;
position: relative;
border-radius: 6px;
display: block;
background: white;
}
/* F1 */
.f1 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
border-radius: 6px;
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f1 input[type="checkbox"]:checked + *:after {
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
content: '\f00c';
text-align: center;
width: 100%;
height: 100%;
position: absolute;
font-weight: 600;
color: white;
pointer-events: none;
font-weight: 600;
top: 0;
z-index: 999;
left: 0;
}
.f1 input[type="checkbox"]:focus + *,
.f1:hover [type="checkbox"] + * { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f1 [type="checkbox"]:checked + * {
background: var(--main-color);
color: white;
box-shadow: 0 0 0 1px var(--main-color);
}
/* F2 */
.f2 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
border-radius: 100px;
cursor: pointer;
width: 3em;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f2 input + .pseudo-checkbox:after {
content: '';
width: calc(1.5em - 4px);
border-radius: 100px;
height: calc(1.5em - 4px);
position: absolute;
top: 2px;
left: 2px;
transition: all 0.15s ease-out;
background: #bbbbbb;
}
.f2 input:checked + .pseudo-checkbox:after {
left: calc(100% - 1.5em + 2px);
content: '';
background: white;
box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}
.f2 input[type="checkbox"]:focus + *,
.f2:hover [type="checkbox"] + * { /* For focusing */
box-shadow: #0000003d 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f2 [type="checkbox"]:checked + *:after {
content: '\f00c';
}
.f2 [type="checkbox"]:checked + * {
background: var(--main-color);
color: white;
box-shadow: 0 0 0 1px var(--main-color);
}
/* F3 */
.f3 .pseudo-checkbox {
background: white;
border-radius: 6px;
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f3 [type="checkbox"]:focus + span + label, .f3 [type="checkbox"]:hover + span + label { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: var(--light-highlight);
}
.f3[data-value="1"] label {
background: var(--main-color);
color: white;
box-shadow: 0 0 0 1px var(--main-color);
}
.f3[data-value="1"] input[type="checkbox"] + span + .pseudo-checkbox {
background: var(--main-color);
box-shadow: 0 0 0 2px var(--main-color)
}
.f3 .halfway {
position: absolute;
top: 0;
box-shadow: rgba(52, 69, 69, 0.16) 1px 0px 0px 0px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
left: 0;
width: 50%;
height: 100%;
transition: all 0.1s ease-out;
z-index: 9;
border-radius: 6px 0 0 6px;
cursor: pointer;
}
.f3 .halfway.active {
background: var(--main-color);
box-shadow: 0 0 0 1px var(--main-color);
}
.f3 .halfway.active:hover {
background: var(--main-color);
}
.f3 .halfway:hover {
background: var(--light-highlight);
box-shadow: rgba(0,0,0,0.2) 1px 0px 0px 0px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f3 .halfway:hover + * {
background: white;
}
.f3 [type="checkbox"]:focus + .halfway.active,
.f3:hover [type="checkbox"] + .halfway.active { /* For focusing */
box-shadow: 1px 0 0 0 var(--main-color);
}
.f3[data-value="1"]:after {
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
content: '\f00c';
text-align: center;
width: 100%;
height: 100%;
position: absolute;
background: var(--main-color);
color: white;
border-radius: 6px;
font-weight: 600;
pointer-events: none;
top: 0;
z-index: 999;
left: 0;
}
/* F4 */
.f4 {
width: 3em;
}
.f4 .pseudo-checkbox {
cursor: pointer;
transition: all 0.1s ease-out;
}
.f4 input[type="checkbox"] + *:after {
transition: all 0.1s ease-out;
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
content: '';
text-align: center;
width: 1em;
height: 1em;
position: absolute;
color: white;
pointer-events: none;
top: 0.25em;
font-weight: 600;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
z-index: -1;
border-radius: 100px;
left: -1px;
background: white;
}
.f4 [type="checkbox"] + * {
z-index: 99999;
border-radius: 100px;
background: transparent;
color: white;
width: 100%;
}
.f4 input:checked + .pseudo-checkbox:after {
left: calc(100% - 1em + 2px);
box-shadow: #0074e600 0px 2px 2px 0px, var(--main-color) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: var(--main-color);
}
.f4 input + .pseudo-checkbox:before, .f4:after {
content: '';
width: 100%;
border-radius: 100px;
z-index: -1;
height: 6px;
position: absolute;
top: calc(50% - 3px);
border-radius: 100px;
left: 0;
transition: all 0.15s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: white;
}
.f4:after {
background: var(--main-color);
width: 0px;
z-index: 99999;
box-shadow: none;
pointer-events: none;
display: block;
}
.f4[data-value="1"]:after {
width: 100%;
}
.f4 input[type="checkbox"]:focus + .pseudo-checkbox:after, .f4:hover input[type="checkbox"] + *:after { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: var(--main-color);
}
/* F5 */
.f5 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
border-radius: 100px;
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f5 input[type="checkbox"] + *:after {
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
content: '\f00c';
text-align: center;
width: 100%;
height: 100%;
position: absolute;
color: white;
pointer-events: none;
top: 0;
border-radius: 100px;
font-weight: 600;
background: var(--main-color);
color: white;
box-shadow: 0 0 0 1px var(--main-color);
clip-path: circle(0% at 0.25em 0.25em);
z-index: 999;
transform: scale(1);
transition: all 0.08s cubic-bezier(0, 1.13, 0.93, 0.82);
left: 0;
}
.f5 [type="checkbox"]:focus + *,
.f5:hover [type="checkbox"] + * { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: linear-gradient(0deg, #f3f9ff, #f4faff);
}
.f5 [type="checkbox"]:checked + *:after {
clip-path: circle(100% at 0.25em 0.25em);
}
/* F6 */
.f6 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
border-radius: 100px;
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f6 [type="checkbox"]:checked + label {
background: var(--main-color);
box-shadow: none;
}
.f6 input[type="checkbox"] + *:after, .f6 input[type="checkbox"] + *:before {
line-height: 1.5em;
content: '';
text-align: center;
width: 70%;
pointer-events: none;
height: 70%;
position: absolute;
pointer-events: none;
box-shadow: 0 2px 2px rgba(0,0,0,0.2);
top: 15%;
transform: scale(0.001);
border-radius: 100px;
background: white;
z-index: 999;
transition: all 0.08s cubic-bezier(0, 1.13, 0.93, 0.82);
left: 15%;
}
.f6 input[type="checkbox"] + *:before {
width: 40%;
height: 40%;
top: 30%;
left: 30%;
z-index: 9999;
background: var(--main-color);
box-shadow: none;
}
.f6 input[type="checkbox"]:checked + *:after, .f6 input[type="checkbox"]:checked + *:before {
transform: scale(1);
}
.f6 > input[type="checkbox"]:focus + *, .f6:hover [type="checkbox"] + * { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
/* F7 */
.f7 {
width: 4em;
cursor: pointer;
}
.f7 .noway, .f7 .fullway, .f7 .thirdway, .f7 .threethirdway {
content: '';
width: 0.75em;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
position: absolute;
top: calc(50% - 0.3525em);
left: -3px;
z-index: 99;
border-radius: 100px;
height: 0.75em;
background: white;
}
.f7 .fullway, .f7 .thirdway, .f7 .threethirdway {
right: -3px;
left: auto;
z-index: 999;
cursor: pointer;
}
.f7 .thirdway {left: calc(33.3% - 0.2em);}
.f7 .threethirdway {left: calc(66.6% - 0.4em);}
.f7 .pseudo-checkbox {
width: inherit;
cursor: pointer;
pointer-events: none;
}
.f7[data-value="0"] .noway,
.f7[data-value="1"] .noway, .f7[data-value="1"] .fullway,
.f7[data-value="1"] .thirdway, .f7[data-value="1"] .threethirdway,
.f7[data-value="0.33"] .noway, .f7[data-value="0.33"] .thirdway,
.f7[data-value="0.66"] .noway, .f7[data-value="0.66"] .thirdway,
.f7[data-value="0.66"] .threethirdway {
background: var(--main-color);
box-shadow: var(--main-color) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px, 0 3px 2px rgba(0,0,0,0.15);
}
.f7 input[type="checkbox"] ~ label:after {
width: inherit;
content: '';
height: 6px;
border-radius: 100px;
top: calc(50% - 3px);
background: white;
position: absolute;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f7 input[type="checkbox"]:focus ~ label:after { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: linear-gradient(0deg, #f3f9ff, #f4faff);
}
/* F8 */
.f8 label {
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
float: left;
width: auto;
border-radius: 6px;
}
.f8 label {
float: left;
/* font-weight: 600; */
cursor: pointer;
padding: 0 0.75em;
color: #848484;
user-select: none;
font-size: 0.75em;
line-height: 1.5em;
width: auto;
height: auto;
}
.f8 input[type="checkbox"] + *:after {
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
transition: height 0.08s cubic-bezier(0, 1.13, 0.93, 0.82), top 0.08s cubic-bezier(0, 1.13, 0.93, 0.82);
content: '\f00c';
text-align: center;
width: 100%;
height: 100%;
height: 0;
position: absolute;
overflow: hidden;
font-weight: 600;
opacity: 0;
color: white;
pointer-events: none;
z-index: 999;
border-radius: 6px;
left: 0;
background: var(--main-color);
top: 100%;
color: white;
box-shadow: 0 0 0 1px var(--main-color);
}
.f8 input[type="checkbox"]:checked + *:after {
top: 0;
opacity: 1;
height: 100%;
}
.f8 [type="checkbox"]:focus + *, .f8:hover [type="checkbox"] + * { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
/* F9 */
.f9 label {
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
float: left;
width: auto;
border-radius: 6px;
}
.f9 label {
float: left;
cursor: pointer;
padding: 0 0.75em 0 2.25em;
color: #848484;
user-select: none;
font-size: 0.75em;
line-height: 1.5em;
width: auto;
height: auto;
}
.f9 input[type="checkbox"] + *:after {
font-family: 'Font Awesome 5 Free';
line-height: 1.5em;
transition: height 0.08s cubic-bezier(0, 1.13, 0.93, 0.82), top 0.08s cubic-bezier(0, 1.13, 0.93, 0.82);
content: '\f00d';
text-align: center;
width: 100%;
height: 100%;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
position: absolute;
overflow: hidden;
pointer-events: none;
z-index: 999;
border-radius: 6px 0 0 6px;
font-weight: 600;
left: 0;
width: 1.5em;
top: 0;
}
.f9 input[type="checkbox"]:checked + *:after {
background: var(--main-color);
box-shadow: 0 0 0 1px var(--main-color);
color: white;
content: '\f00c';
}
.f9 [type="checkbox"]:focus + *, .f9:hover [type="checkbox"] + * { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
/* F10 */
.f10 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
border-radius: 100px;
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f10 input[type="checkbox"]:checked ~ label:after {
font-family: 'Font Awesome 5 Free';
line-height: 2.5em;
content: '\f00c';
text-align: center;
width: 100%;
height: 100%;
font-size: 0.633em;
background: var(--main-color);
position: absolute;
clip-path: circle(40%);
border-radius: 100px;
font-weight: 600;
color: white;
pointer-events: none;
top: 0;
z-index: 999;
left: 0;
}
.f10 input[type="checkbox"]:focus ~ label, .f10:hover [type="checkbox"] ~ label { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: linear-gradient(0deg, #f3f9ff, #f4faff);
}
.f10 [type="checkbox"]:checked ~ label {
color: white;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f10 svg {
position: absolute;
top: -0.65em;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
left: -0.5em;
z-index: 9999;
pointer-events: none;
}
.f10 [type="checkbox"]:checked ~ svg {
animation: dash 2s linear forwards;
}
/* F11 */
.f11 .pseudo-checkbox {
background: linear-gradient(0deg, #f6fbff, white);
cursor: pointer;
transition: all 0.1s ease-out;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 1px 0px, rgba(52, 69, 69, 0.16) 0px 0px 0px 1px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
}
.f11 input[type="checkbox"]:checked ~ label:after {
font-family: 'Font Awesome 5 Free';
line-height: 2.5em;
content: '';
text-align: center;
width: 100%;
height: 100%;
font-size: 0.633em;
background: var(--main-color);
position: absolute;
border-radius: 6px;
box-shadow: none;
font-weight: 600;
color: white;
pointer-events: none;
top: 0;
z-index: 999;
left: 0;
}
.f11 input[type="checkbox"]:focus ~ label, .f11:hover [type="checkbox"] ~ label { /* For focusing */
box-shadow: rgba(0,0,0,0.1) 0px 2px 2px 0px, var(--box-shadow-tint) 0px 0px 0px 2px, rgba(60, 66, 87, 0.08) 0px 2px 5px 0px;
background: linear-gradient(0deg, #f3f9ff, #f4faff);
}
.f11 [type="checkbox"]:checked ~ label {
color: white;
box-shadow: none;
}
.f11 svg {
position: absolute;
top: 0.25em;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
transform: scale3d(1.3, 1, 1);
left: 0.25em;
z-index: 9999;
pointer-events: none;
}
.f11 [type="checkbox"]:checked ~ svg {
animation: dash 2s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
const parent = function(el, match, last) {
var result = [];
for (var p = el && el.parentElement; p; p = p.parentElement) {
result.push(p);
if(p.matches(match)) {
break;
}
}
if(last == 1) {
return result[result.length - 1];
} else {
return result;
}
};
const alternativeSelections = function(item) {
let parentEl = parent(item, '.checkbox-container', true);
let value = item.getAttribute('data-value');
if(item.classList.contains('active')) {
item.classList.remove('active');
parentEl.querySelector('input[type="checkbox"]').value = 'off';
} else {
item.classList.add('active');
parentEl.querySelector('input[type="checkbox"]').value = 'on';
}
parentEl.setAttribute('data-value', value);
parentEl.querySelector('input[type="hidden"]').value = value;
}
document.addEventListener("DOMContentLoaded", function(e) {
document.querySelectorAll('.alt-selection').forEach(function(item) {
item.addEventListener('click', function(e) {
alternativeSelections(this);
});
});
document.querySelectorAll('input[type="checkbox"]').forEach(function(item) {
let parentEl = parent(item, '.checkbox-container', true);
if(item.checked) {
parentEl.setAttribute('data-value', 1);
parentEl.querySelector('input[type="hidden"]').value = 1;
} else {
parentEl.setAttribute('data-value', 0);
parentEl.querySelector('input[type="hidden"]').value = 0;
}
item.addEventListener('change', function(e) {
let value = 0;
let getValue = parseFloat(parentEl.getAttribute('data-value'));
if(this.checked) {
value = 1;
if(parentEl.querySelector('.alt-selection') !== null) {
parentEl.querySelector('.alt-selection').classList.remove('active');
}
}
parentEl.setAttribute('data-value', value);
parentEl.querySelector('input[type="hidden"]').value = value;
});
});
document.querySelectorAll('#colors > div').forEach(function(item) {
item.addEventListener('click', function(e) {
let mainColor = item.getAttribute('data-main-color');
let boxShadow = item.getAttribute('data-box-shadow-tint');
let highlight = item.getAttribute('data-light-highlight');
console.log(mainColor);
document.documentElement.style.setProperty("--main-color", mainColor)
document.documentElement.style.setProperty("--box-shadow-tint", boxShadow)
document.documentElement.style.setProperty("--light-highlight", highlight)
});
})
});
Also see: Tab Triggers