47 CSS Toggles & Switches25 / 47
Bouncy Pebble Organic Toggle
A soft river pebble instead of a circle: the asymmetric blob thumb squashes flat as it launches, stretches mid-flight and wobbles back into shape on landing — squash-and-stretch cartoon physics from one keyframe block, in a warm organic palette.
Published
The code
<section class="tgl-25" aria-label="Bouncy pebble organic toggle">
<label class="tgl-25__row" for="tgl-25-sw">
<span class="tgl-25__lbl">Rain sounds</span>
<input type="checkbox" id="tgl-25-sw" class="tgl-25__sw" role="switch">
</label>
<p class="tgl-25__cap">Squash · stretch · wobble</p>
</section><section class="tgl-25" aria-label="Bouncy pebble organic toggle">
<label class="tgl-25__row" for="tgl-25-sw">
<span class="tgl-25__lbl">Rain sounds</span>
<input type="checkbox" id="tgl-25-sw" class="tgl-25__sw" role="switch">
</label>
<p class="tgl-25__cap">Squash · stretch · wobble</p>
</section>.tgl-25,
.tgl-25 *,
.tgl-25 *::before,
.tgl-25 *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.tgl-25 {
--on: oklch(0.62 0.1 155);
--pebble: #f6f2e8;
font-family: 'Segoe UI',system-ui,sans-serif;
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 26px;
padding: 60px 20px;
background: #e9e4d6;
}
.tgl-25__row {
display: flex;
align-items: center;
gap: 32px;
cursor: pointer;
background: #f3efe3;
border-radius: 22px;
padding: 20px 28px;
box-shadow: 0 12px 30px -20px rgba(90,80,50,.55);
}
.tgl-25__lbl {
font-size: 16px;
font-weight: 600;
color: #4c4a3c;
}
.tgl-25__sw {
appearance: none;
-webkit-appearance: none;
flex: none;
width: 82px;
height: 44px;
border-radius: 26px;
background: #d8d2bf;
position: relative;
cursor: pointer;
transition: background-color .5s;
}
.tgl-25__sw:checked {
background: var(--on);
}
.tgl-25__sw::before {
content: "";
position: absolute;
top: 5px;
left: 5px;
width: 34px;
height: 34px;
border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
background: var(--pebble);
box-shadow: 0 3px 7px rgba(90,80,50,.4);
animation: tgl-25-back .55s cubic-bezier(.3,.7,.4,1) forwards;
}
.tgl-25__sw:checked::before {
animation: tgl-25-go .55s cubic-bezier(.3,.7,.4,1) forwards;
border-radius: 60% 40% 45% 55% / 45% 55% 40% 60%;
}
@keyframes tgl-25-go {
0% {
transform: translateX(0) scale(1,1);
}
15% {
transform: translateX(-3px) scale(.85,1.12);
}
45% {
transform: translateX(20px) scale(1.28,.76);
}
70% {
transform: translateX(38px) scale(.9,1.08);
}
85% {
transform: translateX(38px) scale(1.06,.95);
}
100% {
transform: translateX(38px) scale(1,1);
}
}
@keyframes tgl-25-back {
0% {
transform: translateX(38px) scale(1,1);
}
15% {
transform: translateX(41px) scale(.85,1.12);
}
45% {
transform: translateX(18px) scale(1.28,.76);
}
70% {
transform: translateX(0) scale(.9,1.08);
}
85% {
transform: translateX(0) scale(1.06,.95);
}
100% {
transform: translateX(0) scale(1,1);
}
}
.tgl-25__sw:focus-visible {
outline: 3px solid var(--on);
outline-offset: 4px;
}
.tgl-25__cap {
font-size: 12px;
letter-spacing: .12em;
text-transform: uppercase;
color: #a29a80;
}
@media (prefers-reduced-motion: reduce) {
.tgl-25__sw::before {
animation: none;
transition: transform .2s;
}
.tgl-25__sw:checked::before {
transform: translateX(38px);
}
}.tgl-25,
.tgl-25 *,
.tgl-25 *::before,
.tgl-25 *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.tgl-25 {
--on: oklch(0.62 0.1 155);
--pebble: #f6f2e8;
font-family: 'Segoe UI',system-ui,sans-serif;
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 26px;
padding: 60px 20px;
background: #e9e4d6;
}
.tgl-25__row {
display: flex;
align-items: center;
gap: 32px;
cursor: pointer;
background: #f3efe3;
border-radius: 22px;
padding: 20px 28px;
box-shadow: 0 12px 30px -20px rgba(90,80,50,.55);
}
.tgl-25__lbl {
font-size: 16px;
font-weight: 600;
color: #4c4a3c;
}
.tgl-25__sw {
appearance: none;
-webkit-appearance: none;
flex: none;
width: 82px;
height: 44px;
border-radius: 26px;
background: #d8d2bf;
position: relative;
cursor: pointer;
transition: background-color .5s;
}
.tgl-25__sw:checked {
background: var(--on);
}
.tgl-25__sw::before {
content: "";
position: absolute;
top: 5px;
left: 5px;
width: 34px;
height: 34px;
border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
background: var(--pebble);
box-shadow: 0 3px 7px rgba(90,80,50,.4);
animation: tgl-25-back .55s cubic-bezier(.3,.7,.4,1) forwards;
}
.tgl-25__sw:checked::before {
animation: tgl-25-go .55s cubic-bezier(.3,.7,.4,1) forwards;
border-radius: 60% 40% 45% 55% / 45% 55% 40% 60%;
}
@keyframes tgl-25-go {
0% {
transform: translateX(0) scale(1,1);
}
15% {
transform: translateX(-3px) scale(.85,1.12);
}
45% {
transform: translateX(20px) scale(1.28,.76);
}
70% {
transform: translateX(38px) scale(.9,1.08);
}
85% {
transform: translateX(38px) scale(1.06,.95);
}
100% {
transform: translateX(38px) scale(1,1);
}
}
@keyframes tgl-25-back {
0% {
transform: translateX(38px) scale(1,1);
}
15% {
transform: translateX(41px) scale(.85,1.12);
}
45% {
transform: translateX(18px) scale(1.28,.76);
}
70% {
transform: translateX(0) scale(.9,1.08);
}
85% {
transform: translateX(0) scale(1.06,.95);
}
100% {
transform: translateX(0) scale(1,1);
}
}
.tgl-25__sw:focus-visible {
outline: 3px solid var(--on);
outline-offset: 4px;
}
.tgl-25__cap {
font-size: 12px;
letter-spacing: .12em;
text-transform: uppercase;
color: #a29a80;
}
@media (prefers-reduced-motion: reduce) {
.tgl-25__sw::before {
animation: none;
transition: transform .2s;
}
.tgl-25__sw:checked::before {
transform: translateX(38px);
}
}/* No JavaScript — paired check/uncheck keyframes choreograph anticipate, mid-flight stretch and landing wobble on the blob thumb's transform. */
/* No JavaScript — paired check/uncheck keyframes choreograph anticipate, mid-flight stretch and landing wobble on the blob thumb's transform. */Here's a working CSS Toggles & Switche from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Bouncy Pebble Organic Toggle
Source: https://codefronts.com/components/css-toggles-switches/bouncy-pebble-organic-toggle/
A soft river pebble instead of a circle: the asymmetric blob thumb squashes flat as it launches, stretches mid-flight and wobbles back into shape on landing — squash-and-stretch cartoon physics from one keyframe block, in a warm organic palette.
## HTML
```html
<section class="tgl-25" aria-label="Bouncy pebble organic toggle">
<label class="tgl-25__row" for="tgl-25-sw">
<span class="tgl-25__lbl">Rain sounds</span>
<input type="checkbox" id="tgl-25-sw" class="tgl-25__sw" role="switch">
</label>
<p class="tgl-25__cap">Squash · stretch · wobble</p>
</section>
```
## CSS
```css
.tgl-25,
.tgl-25 *,
.tgl-25 *::before,
.tgl-25 *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.tgl-25 {
--on: oklch(0.62 0.1 155);
--pebble: #f6f2e8;
font-family: 'Segoe UI',system-ui,sans-serif;
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 26px;
padding: 60px 20px;
background: #e9e4d6;
}
.tgl-25__row {
display: flex;
align-items: center;
gap: 32px;
cursor: pointer;
background: #f3efe3;
border-radius: 22px;
padding: 20px 28px;
box-shadow: 0 12px 30px -20px rgba(90,80,50,.55);
}
.tgl-25__lbl {
font-size: 16px;
font-weight: 600;
color: #4c4a3c;
}
.tgl-25__sw {
appearance: none;
-webkit-appearance: none;
flex: none;
width: 82px;
height: 44px;
border-radius: 26px;
background: #d8d2bf;
position: relative;
cursor: pointer;
transition: background-color .5s;
}
.tgl-25__sw:checked {
background: var(--on);
}
.tgl-25__sw::before {
content: "";
position: absolute;
top: 5px;
left: 5px;
width: 34px;
height: 34px;
border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
background: var(--pebble);
box-shadow: 0 3px 7px rgba(90,80,50,.4);
animation: tgl-25-back .55s cubic-bezier(.3,.7,.4,1) forwards;
}
.tgl-25__sw:checked::before {
animation: tgl-25-go .55s cubic-bezier(.3,.7,.4,1) forwards;
border-radius: 60% 40% 45% 55% / 45% 55% 40% 60%;
}
@keyframes tgl-25-go {
0% {
transform: translateX(0) scale(1,1);
}
15% {
transform: translateX(-3px) scale(.85,1.12);
}
45% {
transform: translateX(20px) scale(1.28,.76);
}
70% {
transform: translateX(38px) scale(.9,1.08);
}
85% {
transform: translateX(38px) scale(1.06,.95);
}
100% {
transform: translateX(38px) scale(1,1);
}
}
@keyframes tgl-25-back {
0% {
transform: translateX(38px) scale(1,1);
}
15% {
transform: translateX(41px) scale(.85,1.12);
}
45% {
transform: translateX(18px) scale(1.28,.76);
}
70% {
transform: translateX(0) scale(.9,1.08);
}
85% {
transform: translateX(0) scale(1.06,.95);
}
100% {
transform: translateX(0) scale(1,1);
}
}
.tgl-25__sw:focus-visible {
outline: 3px solid var(--on);
outline-offset: 4px;
}
.tgl-25__cap {
font-size: 12px;
letter-spacing: .12em;
text-transform: uppercase;
color: #a29a80;
}
@media (prefers-reduced-motion: reduce) {
.tgl-25__sw::before {
animation: none;
transition: transform .2s;
}
.tgl-25__sw:checked::before {
transform: translateX(38px);
}
}
```
## JavaScript
```js
/* No JavaScript — paired check/uncheck keyframes choreograph anticipate, mid-flight stretch and landing wobble on the blob thumb's transform. */
```Here's a working CSS Toggles & Switche from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Bouncy Pebble Organic Toggle
Source: https://codefronts.com/components/css-toggles-switches/bouncy-pebble-organic-toggle/
A soft river pebble instead of a circle: the asymmetric blob thumb squashes flat as it launches, stretches mid-flight and wobbles back into shape on landing — squash-and-stretch cartoon physics from one keyframe block, in a warm organic palette.
## HTML
```html
<section class="tgl-25" aria-label="Bouncy pebble organic toggle">
<label class="tgl-25__row" for="tgl-25-sw">
<span class="tgl-25__lbl">Rain sounds</span>
<input type="checkbox" id="tgl-25-sw" class="tgl-25__sw" role="switch">
</label>
<p class="tgl-25__cap">Squash · stretch · wobble</p>
</section>
```
## CSS
```css
.tgl-25,
.tgl-25 *,
.tgl-25 *::before,
.tgl-25 *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.tgl-25 {
--on: oklch(0.62 0.1 155);
--pebble: #f6f2e8;
font-family: 'Segoe UI',system-ui,sans-serif;
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 26px;
padding: 60px 20px;
background: #e9e4d6;
}
.tgl-25__row {
display: flex;
align-items: center;
gap: 32px;
cursor: pointer;
background: #f3efe3;
border-radius: 22px;
padding: 20px 28px;
box-shadow: 0 12px 30px -20px rgba(90,80,50,.55);
}
.tgl-25__lbl {
font-size: 16px;
font-weight: 600;
color: #4c4a3c;
}
.tgl-25__sw {
appearance: none;
-webkit-appearance: none;
flex: none;
width: 82px;
height: 44px;
border-radius: 26px;
background: #d8d2bf;
position: relative;
cursor: pointer;
transition: background-color .5s;
}
.tgl-25__sw:checked {
background: var(--on);
}
.tgl-25__sw::before {
content: "";
position: absolute;
top: 5px;
left: 5px;
width: 34px;
height: 34px;
border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
background: var(--pebble);
box-shadow: 0 3px 7px rgba(90,80,50,.4);
animation: tgl-25-back .55s cubic-bezier(.3,.7,.4,1) forwards;
}
.tgl-25__sw:checked::before {
animation: tgl-25-go .55s cubic-bezier(.3,.7,.4,1) forwards;
border-radius: 60% 40% 45% 55% / 45% 55% 40% 60%;
}
@keyframes tgl-25-go {
0% {
transform: translateX(0) scale(1,1);
}
15% {
transform: translateX(-3px) scale(.85,1.12);
}
45% {
transform: translateX(20px) scale(1.28,.76);
}
70% {
transform: translateX(38px) scale(.9,1.08);
}
85% {
transform: translateX(38px) scale(1.06,.95);
}
100% {
transform: translateX(38px) scale(1,1);
}
}
@keyframes tgl-25-back {
0% {
transform: translateX(38px) scale(1,1);
}
15% {
transform: translateX(41px) scale(.85,1.12);
}
45% {
transform: translateX(18px) scale(1.28,.76);
}
70% {
transform: translateX(0) scale(.9,1.08);
}
85% {
transform: translateX(0) scale(1.06,.95);
}
100% {
transform: translateX(0) scale(1,1);
}
}
.tgl-25__sw:focus-visible {
outline: 3px solid var(--on);
outline-offset: 4px;
}
.tgl-25__cap {
font-size: 12px;
letter-spacing: .12em;
text-transform: uppercase;
color: #a29a80;
}
@media (prefers-reduced-motion: reduce) {
.tgl-25__sw::before {
animation: none;
transition: transform .2s;
}
.tgl-25__sw:checked::before {
transform: translateX(38px);
}
}
```
## JavaScript
```js
/* No JavaScript — paired check/uncheck keyframes choreograph anticipate, mid-flight stretch and landing wobble on the blob thumb's transform. */
```How this works
The thumb's organic silhouette is an asymmetric 8-value border-radius (40% 60% 55% 45% / 55% 45% 60% 40%). Motion is two keyframe animations — one for checking, one for unchecking — that choreograph translateX WITH scaleX/scaleY: anticipate (squash 1.15/.85), launch (stretch 1.25/.8 mid-travel), land (overshoot), wobble (two diminishing counter-squashes). A transition can't sequence this; keyframes can.
Each state applies its own animation name with forwards fill, so the same choreography plays mirrored on the way back. The border-radius values also morph slightly between states, making the pebble feel hand-formed rather than stamped.
Make it yours
- Exaggerate cartoon-ness: push mid-flight stretch to 1.4/.7.
- Reshape the pebble by editing the 8 border-radius percentages.
- Palette swap: sage/cream here; try clay/sand or moss/stone.
- Add a landing dust-puff: a ::after ring that scales+fades on the landing keyframe.
Gotchas — read before shipping
- Two named animations (in/out) are required — a single transition cannot express anticipate→stretch→wobble.
- The uncheck animation also runs once on first load; harmless, but start the demo checked if that bothers you.
- Keep all squash on transform scale — animating border-radius alone mid-flight jitters on low-end GPUs.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 15.4+ | 113+ | 111+ |
Floor set by oklch() as this demo is written. The core technique itself goes back further — Chrome 43+.
Keyframe animations on transform; universal support.