پیشنمایش زنده
کد HTML
<div class="uiverse-wrapper">
<label class="cb-container">
<input type="checkbox" />
<div class="checkmark">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="4"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
</div>
</label>
</div>
کد CSS
/* uiverse.io styling */
.uiverse-wrapper {
--size: 40px;
--color-default: #d1d1d1;
--color-active: #000000;
--transition: 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6);
}
.cb-container {
display: block;
position: relative;
cursor: pointer;
width: var(--size);
height: var(--size);
user-select: none;
}
/* Hide the native checkbox */
.cb-container input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* The custom box */
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: white;
border: 3px solid var(--color-default);
border-radius: 12px;
transition: var(--transition);
display: flex;
justify-content: center;
align-items: center;
box-shadow: 4px 4px 0px var(--color-default);
}
/* Inside SVG styling */
.checkmark svg {
width: 20px;
height: 20px;
color: white;
transform: scale(0) rotate(-45deg);
transition: var(--transition);
filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}
/* On Hover: Slight lift */
.cb-container:hover .checkmark {
transform: translate(-2px, -2px);
box-shadow: 6px 6px 0px var(--color-default);
}
/* CHECKED STATE */
.cb-container input:checked ~ .checkmark {
background-color: var(--color-active);
border-color: var(--color-active);
box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.2);
transform: scale(1.1) rotate(5deg);
}
/* When checked, make the SVG pop out */
.cb-container input:checked ~ .checkmark svg {
transform: scale(1) rotate(0deg);
}
/* Active "Pressed" state */
.cb-container:active .checkmark {
transform: translate(2px, 2px);
box-shadow: 2px 2px 0px var(--color-default);
}