پیش‌نمایش زنده
کد HTML
<label class="checkbox-container">
  <input checked="" type="checkbox" />
  <div class="checkmark"></div>
</label>
کد CSS
/* Container styling */
.checkbox-container {
  display: flex;
  align-items: center;
  font-size: 1em;
  cursor: pointer;
  user-select: none;

  /* Scoped variables with updated colors */
  --checkmark-size: 2.5em;
  --border-color: #444; /* Darker gray border */
  --checked-bg-color: #ffab40; /* Amber when checked */
  --checked-border-color: #ffa726; /* Amber border */
  --checkmark-color: white; /* White checkmark */
  --focus-outline-color: rgba(255, 171, 64, 0.5); /* Amber glow for focus */
}

/* Hide default checkbox */
.checkbox-container input {
  display: none;
}

/* Checkmark styling */
.checkmark {
  width: var(--checkmark-size);
  height: var(--checkmark-size);
  border: 2px solid var(--border-color);
  border-radius: 0.25em;
  background-color: transparent;
  position: relative;
  margin-right: 0.5em;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Checked state */
.checkbox-container input:checked + .checkmark {
  background-color: var(--checked-bg-color);
  border-color: var(--checked-border-color);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Checkmark icon */
.checkmark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.75em;
  height: 0.75em;
  background-color: transparent;
  border-radius: 0.1em;
  transform: translate(-50%, -50%);
  transition:
    background-color 0.3s ease,
    transform 0.3s ease;
}

.checkbox-container input:checked + .checkmark::after {
  background-color: var(--checkmark-color);
  transform: scale(1);
  animation: checkmark-fade-in 0.3s ease forwards;
}

/* Hover and Focus */
.checkmark:hover {
  border-color: var(--checked-bg-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.checkbox-container input:focus + .checkmark {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-outline-color);
}

/* Checkmark animation */
@keyframes checkmark-fade-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
نوع: checkbox
تاریخ ایجاد: 2026/06/05
آخرین بروزرسانی: 2026/06/05