Gleitender Tab-Toggle
Gleitender Tab-Toggle: CSS-Button. Kopiere die Regeln oder den Prompt, der das Ergebnis nachbaut.
CSS
.btn-088 {
position: relative;
display: inline-grid;
grid-template-columns: 1fr 1fr;
background: #e5e7eb;
border-radius: 999px;
padding: 4px;
isolation: isolate
}
.btn-088 input {
position: absolute;
opacity: 0;
width: 0;
height: 0
}
.btn-088 label {
position: relative;
z-index: 1;
font: 600 13px/1 system-ui,sans-serif;
color: #4b5563;
text-align: center;
padding: 9px 20px;
border-radius: 999px;
cursor: pointer;
transition: color .2s
}
.btn-088 span {
position: absolute;
top: 4px;
left: 4px;
width: calc(50% - 4px);
height: calc(100% - 8px);
background: #fff;
border-radius: 999px;
box-shadow: 0 1px 3px rgba(0,0,0,.15);
transition: transform .25s
}
.btn-088 input:nth-of-type(1):checked~span {
transform: translateX(0)
}
.btn-088 input:nth-of-type(2):checked~span {
transform: translateX(100%)
}
.btn-088 input:checked+label {
color: #111827
}
.btn-088 label:hover {
color: #111827
}
.btn-088 input:focus-visible+label {
outline: 2px solid #111827;
outline-offset: -2px
}
.btn-088 label:active {
color: #000
}
HTML
<div class="btn-088"><input type="radio" name="b088" id="b088a" checked><label for="b088a">Monthly</label><input type="radio" name="b088" id="b088b"><label for="b088b">Yearly</label><span></span></div>Prompt
Ein Zwei-Optionen-Toggle (Monthly / Yearly) aus Radio-Inputs: eine graue #e5e7eb Pillen-Schiene mit 4px Padding, zwei gleich große Labels in 13px semibold Grau #4b5563 und ein weißer Pillen-Daumen mit kleinem Schatten, der unter die gewählte Option gleitet (250ms). Das gewählte Label wird #111827. Fokus zeigt eine 2px dunkle Outline innerhalb des Labels.