Components

Toggle

Allows the user to change a setting between two states.

HTML
<input type="checkbox" id="toggle" class="toggle">
<label for="toggle" class="toggle-label icon">
    <div class="italic-icon"></div>
</label>
                                
CSS
.toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-label {
    cursor: pointer;
    display: inline-block;
    padding: 0.8em;
    border: 0.5px solid transparent;
    background-color: transparent;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.toggle-label:hover {
    opacity: 0.6;
}

.toggle:checked ~ .toggle-label {
    background-color: var(--subtler-color);
    color: var(--highlight-color);
    border-color: var(--subtler-color);
    opacity: 1;
}

.italic-icon {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    mask-image: url('media/icons/italic.svg');
    -webkit-mask-image: url('media/icons/italic.svg');
    mask-size: contain;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-repeat: no-repeat;
    background-color: var(--highlight-color);
}