Checkbox

Checkboxes são utilizados quando, dentro de um range de opções, é dado ao usuário a possibilidade de múltipla escolha.

Estados de interação

Normal
Hover
Selected
Disabled

Código

HTML
Copiar código
Copiar Código
Exibir código
<label class="checkbox"> <input type="checkbox" /> <span class="text"> Text here </span> <span class="checkmark"></span> </label>
SASS
Copiar código
Copiar Código
Exibir código
.checkbox{ display: block; position: relative; padding-left: 35px; padding-right: 10px; cursor: pointer; user-select: none; min-height: 25px; margin: 13px 0; box-sizing: border-box; width: 250px; max-width: 100%; .text{ font-family: Lato; font-size: 1em; font-weight: normal; font-style: normal; font-stretch: normal; line-height: 26px; letter-spacing: normal; color: #323232; white-space: nowrap; display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; transition: .4s; &:hover{ color: #1b68ff; } } input { position: absolute; opacity: 0; cursor: pointer; &:checked + .text { color: #3153f5; } &:checked ~ .checkmark { border-color: #3153f5; &:after{ display: block; } } } .checkmark { position: absolute; top: 0; left: 0; height: 22px; width: 22px; background-color: #fff; border: 1px solid #7f7f7f; border-radius: 4px; &:after { content: ""; position: absolute; display: none; background-image: url(/img/input-checkbox-icon.svg); background-size: 16px; background-repeat: no-repeat; width: 15px; height: 11px; top: 5px; left: 4px; } } &:hover input ~ .checkmark { border-color: #1b68ff; transition: .4s; } &.hovered{ .text{ color: #1b68ff; } .checkmark{ border-color: #1b68ff; } input { &:checked ~ .checkmark { border-color: #1b68ff; } } } &.selected{ .text{ color: #3153f5; } .checkmark{ border-color: #3153f5; } input { &:checked ~ .checkmark { border-color: #3153f5; } } } &.disabled{ pointer-events: none; .text{ color: #9b9b9b; } .checkmark{ background-color: #ebebeb; border-color: #ebebeb; } input { border-color: #9b9b9b; &:checked ~ .checkmark { border-color: #9b9b9b; } } } }