# On/Off css Swich

**URL:** <https://discourse.nodered.org/t/on-off-css-swich/30593>\
**Category:** Dashboard\
**Created:** [23 July 2020 09:10 UTC](https://discourse.nodered.org/t/on-off-css-swich/30593 "2020-07-23T09:10:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ataraxial](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ataraxial/32/41138_2.png) [@Ataraxial](https://discourse.nodered.org/u/Ataraxial)\
**Post date:** [23 July 2020 09:10 UTC](https://discourse.nodered.org/t/on-off-css-swich/30593/1 "2020-07-23T09:10:53Z")

</div>

Good morning,  
I have found a Switch button in CSS that I want to apply to my dashboars, I have put it in a template node and the button works visually very well.  
What I no longer know is how to get a true, and a false off in off state. I am very new to css, can someone help me out?

```auto
<style>/* Checkbox switch */

.checkbox-switch {
    cursor: pointer;
    display: inline-block;
    overflow: hidden;
    position: relative;
    text-align: left;
    width: 80px;
    height: 30px;
    -webkit-border-radius: 30px;
    border-radius: 30px;
    line-height: 1.2;
    font-size: 14px;
}

.checkbox-switch input.input-checkbox {
	position: absolute;
	left: 0;
	top: 0;
	width: 80px;
	height: 30px;
	padding: 0;
	margin: 0;
	opacity: 0;
	z-index: 2;
	cursor: pointer;
}

.checkbox-switch .checkbox-animate {
    position: relative;
    width: 80px;
    height: 30px;
    background-color: #95a5a6;
    -webkit-transition: background 0.25s ease-out 0s;
    transition: background 0.25s ease-out 0s;
}

.checkbox-switch .checkbox-animate:before {
	content: "";
	display: block;
	position: absolute;
	width: 20px;
	height: 20px;
	border-radius: 10px;
	-webkit-border-radius: 10px;
	background-color: #7f8c8d;
	top: 5px;
	left: 5px;
	 -webkit-transition: left 0.3s ease-out 0s;
    transition: left 0.3s ease-out 0s;
    z-index: 10;
}

.checkbox-switch input.input-checkbox:checked + .checkbox-animate {
	background-color: #2ecc71;
}

.checkbox-switch input.input-checkbox:checked + .checkbox-animate:before {
	left: 55px;
	background-color: #27ae60;
}

.checkbox-switch .checkbox-off,
.checkbox-switch .checkbox-on {
	float: left;
	color: #fff;
	font-weight: 700;
	padding-top: 6px;
	 -webkit-transition: all 0.3s ease-out 0s;
    transition: all 0.3s ease-out 0s;
}

.checkbox-switch .checkbox-off {
	margin-left: 30px;
	opacity: 1;
}

.checkbox-switch .checkbox-on {
	display: none;
	float: right;
	margin-right: 35px;
	opacity: 0;
}

.checkbox-switch input.input-checkbox:checked + .checkbox-animate .checkbox-off {
	display: none;
	opacity: 0;
}

.checkbox-switch input.input-checkbox:checked + .checkbox-animate .checkbox-on {
	display: block;
	opacity: 1;
}
</style>
<div class="checkbox-switch">
			<input type="checkbox" checked="" onchange="send({payload : {row:$index, enabled:aktiv}})" onchangechecked="row.aktiv==='true'"value="1" name="status" class="input-checkbox" id="toolbar-active">
			<div class="checkbox-animate">
				<span class="checkbox-off">OFF</span>
				<span class="checkbox-on">ON</span>
			</div>
		</div>

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 August 2020 09:10 UTC](https://discourse.nodered.org/t/on-off-css-swich/30593/2 "2020-08-22T09:10:58Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
