YL

FORM & INPUT

自定义勾选框Custom Checkbox & Radio

重绘的勾选框:选中时品牌色填充 + 白色对勾弹出,单选用内圆表示。

中英对照

中文
自定义勾选框
英文
Custom Checkbox & Radio
别名
美化复选框、单选框、Check & Radio
一句话
重绘的勾选框:选中时品牌色填充 + 白色对勾弹出,单选用内圆表示。

效果预览

接收产品更新邮件 已阅读并同意服务协议 订阅行业周报 按月付费 按年付费(省 20%)

适合用在哪

所有表单、筛选器、协议勾选、多选列表。

不适合:立刻生效的单一布尔设置:用开关更符合预期;选项超过一屏还用原生大列表时,考虑虚拟列表或搜索多选。

和相近模式的区别

开关Toggle Switch

开关 = 立即生效的开/关;自定义勾选框 = 表单多选、协议勾选、筛选,常随提交一起生效。

星级评分输入Star Rating Input

星级是 1–5 序数评价;勾选是互不排斥的多项或单一同意项。

容易踩的坑

  • 用 display:none 隐藏原生 input,复选框失去键盘焦点和读屏语义。
  • 可点区域只有 16px 的方框,没把 label 包进来,移动端很难点中。
  • 未选中态描边颜色对比度低于 3:1,在白底上几乎看不出这里有个框。

设计提示词 · Prompt

自定义勾选框(Custom Checkbox):15-20px 见方、4-5px 圆角、1.5px 描边;选中态背景填品牌色、描边同步变色,白色对勾用 scale 0→1 弹出(150ms cubic-bezier(.34,1.56,.64,1) 有回弹)。单选框改为全圆角,选中时描边变粗(border-width 4-5px)形成"空心圆环"效果,不需要内部圆点元素。整组键盘可访问(保留原生 input 的 :focus-visible 光圈)。点击热区至少 44×44px(热区大于视觉尺寸)。
Custom Checkbox: 15-20px square, 4-5px border radius, 1.5px border; in the checked state the background fills with brand color and the border changes color in sync, and a white checkmark pops in via scale 0→1 (150ms cubic-bezier(.34,1.56,.64,1) with overshoot). Radio buttons use a full border radius; when selected the border thickens (border-width 4-5px) to form a "hollow ring" effect, without needing an inner dot element. The whole group is keyboard accessible (keep the native input's :focus-visible ring). The click target is at least 44×44px (hit area larger than the visual size).

可复制 CSS

自包含的最小实现,粘贴到空白页面即可生效;类名可以按项目规范改名。

/* 复选方框 + 单选空心圆环 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font: 14px/1.4 system-ui, sans-serif;
  color: #111827;
  cursor: pointer;
}
.check input {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid #9ca3af;
  border-radius: 5px;
  background: #fff;
  display: grid;
  place-items: center;
  transition: background-color .15s ease, border-color .15s ease;
}
.check input:checked {
  background: #4f46e5;
  border-color: #4f46e5;
}
.check input:checked::after {
  content: "";
  width: 8px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: scale(0) rotate(-45deg);
  animation: check-pop .15s cubic-bezier(.34, 1.56, .64, 1) forwards;
}
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked {
  background: #fff;
  border-width: 5px;
  border-color: #4f46e5;
}
.check input[type="radio"]:checked::after { content: none; }
.check input:focus-visible { outline: 2px solid #4f46e5; outline-offset: 3px; }
@keyframes check-pop {
  to { transform: scale(1) rotate(-45deg); }
}
@media (prefers-reduced-motion: reduce) {
  .check input:checked::after { animation: none; transform: scale(1) rotate(-45deg); }
}

演示 HTML 结构

<div class="s d-checks">
  <span class="d-ck"><span class="d-ck__box is-on"></span>接收产品更新邮件</span>
  <span class="d-ck"><span class="d-ck__box is-on is-on--g"></span>已阅读并同意服务协议</span>
  <span class="d-ck"><span class="d-ck__box"></span>订阅行业周报</span>
  <span class="d-ck"><span class="d-ck__radio is-on"></span>按月付费</span>
  <span class="d-ck"><span class="d-ck__radio"></span>按年付费(省 20%)</span>
</div>

常见问题

自定义勾选框的英文是什么?

自定义勾选框的英文是 Custom Checkbox & Radio。常见英文别名还包括 Check & Radio。

Custom Checkbox & Radio 的中文是什么?

Custom Checkbox & Radio 的中文是「自定义勾选框」。常见中文别名还包括 美化复选框、单选框。重绘的勾选框:选中时品牌色填充 + 白色对勾弹出,单选用内圆表示。

单选为什么用加粗描边而不是内圆点?

border-width 提到 4–5px 形成空心圆环,少一个伪元素,视觉也更干净;需要经典内圆点时再加 ::after 圆点即可。

点击热区怎么保证 44×44?

视觉框可以 15–20px,但 label 整行 min-height:44px,让文字区域也可点,满足触控目标。

常见搭配

同一页面里经常和「自定义勾选框」一起出现的模式,可以收藏后用「组合收藏为整页提示词」一起交给 AI。

标签