☑️ Checkbox
Кастомные чекбоксы с различными стилями
← Назад к Формы
Кастомный
HTML
<label class="checkbox-custom"> <input type="checkbox" checked> <span class="checkbox-custom-mark"></span> <span class="checkbox-custom-label">I agree to terms</span> </label>
CSS
.checkbox-custom {
display: inline-flex;
align-items: center;
gap: 0.75rem;
cursor: pointer;
user-select: none;
}
.checkbox-custom input {
display: none;
}
.checkbox-custom-mark {
width: 22px;
height: 22px;
border: 2px solid #d0d0d0;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
flex-shrink: 0;
}
.checkbox-custom input:checked + .checkbox-custom-mark {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-color: transparent;
}
.checkbox-custom input:checked + .checkbox-custom-mark::after {
content: '✓';
color: white;
font-size: 14px;
font-weight: bold;
}
.checkbox-custom-label {
font-size: 0.95rem;
color: #1a1a2e;
}
Toggle Style
HTML
<label class="checkbox-toggle"> <input type="checkbox" checked> <span class="checkbox-toggle-slider"></span> <span class="checkbox-toggle-label">Enable notifications</span> </label>
CSS
.checkbox-toggle {
display: inline-flex;
align-items: center;
gap: 0.75rem;
cursor: pointer;
user-select: none;
}
.checkbox-toggle input {
display: none;
}
.checkbox-toggle-slider {
width: 44px;
height: 24px;
background: #d0d0d0;
border-radius: 12px;
position: relative;
transition: all 0.3s ease;
flex-shrink: 0;
}
.checkbox-toggle-slider::after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 20px;
height: 20px;
background: white;
border-radius: 50%;
transition: all 0.3s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.checkbox-toggle input:checked + .checkbox-toggle-slider {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.checkbox-toggle input:checked + .checkbox-toggle-slider::after {
left: 22px;
}
.checkbox-toggle-label {
font-size: 0.95rem;
color: #1a1a2e;
}
С описанием
HTML
<label class="checkbox-desc">
<input type="checkbox" checked>
<span class="checkbox-desc-mark"></span>
<div class="checkbox-desc-content">
<div class="checkbox-desc-title">Subscribe to newsletter</div>
<div class="checkbox-desc-text">Get weekly updates and offers</div>
</div>
</label>
CSS
.checkbox-desc {
display: flex;
align-items: flex-start;
gap: 0.75rem;
cursor: pointer;
user-select: none;
padding: 1rem;
border: 2px solid #e0e0e0;
border-radius: 10px;
transition: all 0.3s ease;
width: 280px;
}
.checkbox-desc:hover {
border-color: #667eea;
}
.checkbox-desc input {
display: none;
}
.checkbox-desc-mark {
width: 22px;
height: 22px;
border: 2px solid #d0d0d0;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
flex-shrink: 0;
margin-top: 2px;
}
.checkbox-desc input:checked + .checkbox-desc-mark {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-color: transparent;
}
.checkbox-desc input:checked + .checkbox-desc-mark::after {
content: '✓';
color: white;
font-size: 14px;
font-weight: bold;
}
.checkbox-desc-content {
flex: 1;
}
.checkbox-desc-title {
font-size: 0.95rem;
font-weight: 600;
color: #1a1a2e;
margin-bottom: 0.25rem;
}
.checkbox-desc-text {
font-size: 0.8rem;
color: #666;
}