Emoji Checkbox with Happy (On) and Sad (Off) Face


Emoji Checkbox

CSS:

.checkbox-emoji {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
}
.checkbox-emoji input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkmark-emoji {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}
.checkbox-emoji:hover input ~ .checkmark-emoji {
    background-color: #ccc;
}
.checkbox-emoji input:checked ~ .checkmark-emoji {
    background-color: #2196F3;
}
.checkmark-emoji:after {
    content: "😞";
    display: block;
}
.checkbox-emoji input:checked ~ .checkmark-emoji:after {
    content: "😊";
}

Facing issues? Have Questions? Post them here! I am happy to answer!







Author Info:

Rakesh (He/Him) has a Masters Degree in Computer Science with over 15+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap