Skip to content

Checkbox 多选

*UI备注

此模块为须严格遵守设计规范的模块

CSS样式

全部checkbox样式代码:

查看代码
css
/* HnuiIcon */
@import url('./icon.css');

/* 全局css变量 */

:root {
  /* #region vars-BrandColor */

  /* 品牌色 */
  --hnui-brand-color: #1f78ff;
  --hnui-brand-color1: #005ce5;
  --hnui-brand-color2: #4b83f7;
  --hnui-brand-color3: #3384ff;
  --hnui-brand-color4: #599bff;
  --hnui-brand-color5: #80b2ff;
  --hnui-brand-color6: #b2d1ff;
  --hnui-brand-color7: #cce0ff;
  --hnui-brand-color8: #d9e8ff;
  --hnui-brand-color9: #ebf3ff;
  --hnui-brand-color10: #f2f7ff;

  /* 状态颜色 */
  --hnui-brand-color-normal: var(--hnui-brand-color);
  --hnui-brand-color-hover: var(--hnui-brand-color3);
  --hnui-brand-color-active: var(--hnui-brand-color1);
  --hnui-brand-color-elected: var(--hnui-brand-color9);
  --hnui-brand-color-disabled: var(--hnui-brand-color7);

  --hnui-brand-color-disabled-border: var(--hnui-brand-color6);
  --hnui-brand-color-disabled-bg: var(--hnui-brand-color10);

  /* #endregion vars-BrandColor */

  /* #region vars-DomainColor */

  /* 功能色 */
  --hnui-success-color: #2ba471;
  --hnui-success-hover-color: #51bd90;
  --hnui-success-active-color: #2ba471;

  --hnui-warning-color: #faad14;
  --hnui-warning-hover-color: #ffc146;
  --hnui-warning-active-color: #db960b;

  --hnui-danger-color: #ff4d4d;
  --hnui-danger-hover-color: #ff7676;
  --hnui-danger-active-color: #d82a2a;

  --hnui-info-color: #8d97a6;
  --hnui-info-hover-color: #b2b7c0;
  --hnui-info-active-color: #707a89;

  /* #endregion vars-DomainColor */

  /* #region vars-NeutralColor */
  /* 中性色 */

  /* 标题文字 */
  --hnui-neutral-color-1: #2d2e33;

  /* 正文、重要信息文字、按钮文字、输入框正常状态文字等 */
  --hnui-neutral-color-2: #43454d;

  /* 内容文字、说明叙述文字 */
  --hnui-neutral-color-3: #5d606a;

  /* 提示性文字、辅助文本 */
  --hnui-neutral-color-4: #9298a0;

  /* 禁用文本 */
  --hnui-neutral-color-5: #b7bdc7;

  /* 描边格描边、输入文本描边、下拉选择描边等 */
  --hnui-neutral-color-6: #dfe2e7;

  /* 全局背景、禁用状态、分割线等 */
  --hnui-neutral-color-7: #f0f2f5;

  /* 最低颜色等 */
  --hnui-neutral-color-8: #fafbfc;

  /* #endregion vars-NeutralColor */

  /* 默认文字颜色 */
  --hnui-text-color: var(--hnui-neutral-color-2);

  --hnui-info-bg: #eceff4;
  --hnui-info-bg2: #e7e7e7;

  --hnui-color-white: #fff;
  --hnui-color-black: #000;

  --hnui-border-width: 1px;
  --hnui-border-dashed-width: 2px;
  --hnui-border-color: var(--hnui-neutral-color-6);

  --hnui-disabled-bg-color: var(--hnui-neutral-color-7);
  --hnui-disabled-color: var(--hnui-neutral-color-5);

  --hnui-control-height: 32px;
  --hnui-control-height-sm: 24px;
  --hnui-control-height-lg: 40px;

  --hnui-control-transparent: transparent;
}

.dark {
  --hnui-brand-color6: rgb(50, 59, 74);
  --hnui-brand-color7: #30353d;
  --hnui-brand-color8: #42484f;
  --hnui-brand-color9: #4c4f54;
  --hnui-brand-color10: #29292c;

  /* 中性色 */

  /* 标题文字 */
  --hnui-neutral-color-1: #c4c8dc;

  /* 正文、重要信息文字、按钮文字、输入框正常状态文字等 */
  --hnui-neutral-color-2: #b9bed3;

  /* 内容文字、说明叙述文字 */
  --hnui-neutral-color-3: #afb5c7;

  /* 提示性文字、辅助文本 */
  --hnui-neutral-color-4: #6a6f75;

  /* 禁用文本 */
  --hnui-neutral-color-5: #53565b;

  /* 描边格描边、输入文本描边、下拉选择描边等 */
  --hnui-neutral-color-6: #59595a;

  /* 全局背景、禁用状态、分割线等 */
  --hnui-neutral-color-7: #343535;

  /* 最低颜色等 */
  --hnui-neutral-color-8: #151516;

  --hnui-info-bg: #393b3d;

  --hnui-color-white: #000;
  --hnui-color-black: #fff;

  --hnui-control-transparent: transparent;
}

*,
::before,
::after {
  box-sizing: border-box;
}

body {
  color: var(--hnui-neutral-color-2);
}

/* #region vars-FontFamily */
@font-face {
  font-family: 'DIN';
  src: url('/fonts/D-DIN-PRO/D-DIN-PRO.woff2') format('woff2'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.woff') format('woff'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.ttf') format('truetype'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.eot') format('embedded-opentype'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

/* 使用数字字体 */
.use-font {
  font-family: DIN;
}
/* #endregion vars-FontFamily */

/* #region vars-BoxShadow */
/* 一级投影(默认向下) */
.hnui-box-shadow {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.18);
}
.hnui-box-shadow.hover,
.hnui-box-shadow:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.18);
}

/* 二级投影(默认向下) */
.hnui-box-shadow_l2 {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.12);
}
.hnui-box-shadow_l2.hover,
.hnui-box-shadow_l2:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.12);
}

/* 三级投影(默认向下) */
.hnui-box-shadow_l3 {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.06);
}
.hnui-box-shadow_l3.hover,
.hnui-box-shadow_l3:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.06);
}
/* #endregion vars-BoxShadow */
css

.hnui-checkbox {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding-left: 1.5em;
}

.hnui-checkbox-input {
  --hnui-checkbox-bg: transparent;
  width: 16px;
  height: 16px;
  margin: 0 4px 0 0;
  background-color: var(--hnui-checkbox-bg);
  background-image: var(--hnui-checkbox-bg-image);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: var(--hnui-border-width) solid var(--hnui-border-color);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-print-color-adjust: exact;
  color-adjust: exact;
  print-color-adjust: exact;
  cursor: pointer;
}

.hnui-checkbox .hnui-checkbox-input {
  float: left;
  margin-left: -1.5em;
}

.hnui-checkbox-input[type="checkbox"] {
  border-radius: 3px;
}

.hnui-checkbox-input[indeterminate],
.hnui-checkbox-input.indeterminate,
.hnui-checkbox-input:checked {
  background-color: var(--hnui-brand-color-normal);
  border-color: var(--hnui-brand-color-normal);
}

.hnui-checkbox.hover .hnui-checkbox-input:not(:disabled),
.hnui-checkbox:hover .hnui-checkbox-input:not(:disabled) {
  border-color: var(--hnui-brand-color-normal);
}

.hnui-checkbox-input:disabled[indeterminate][type="checkbox"]:not(:checked),
.hnui-checkbox-input:disabled.indeterminate[type="checkbox"]:not(:checked) {
  --hnui-checkbox-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 2'%3E%3Cpath fill='%23B0B0B0' d='M4 0h8v2H4z'/%3E%3C/svg%3E");
}

.hnui-checkbox-input[indeterminate][type="checkbox"]:not(:checked),
.hnui-checkbox-input.indeterminate[type="checkbox"]:not(:checked) {
  --hnui-checkbox-bg-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 2'%3E%3Cpath fill='%23fff' d='M4 0h8v2H4z'/%3E%3C/svg%3E");
}

.hnui-checkbox-input:disabled:checked[type="checkbox"] {
  --hnui-checkbox-bg-image: url("data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M411.755 634.987l-226.56-226.56-58.838 58.816L411.755 752.64l457.088-457.088-58.838-58.816-398.25 398.25z' fill='%23B0B0B0'/%3E%3C/svg%3E");
}

.hnui-checkbox-input:checked[type="checkbox"] {
  --hnui-checkbox-bg-image: url("data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M411.755 634.987l-226.56-226.56-58.838 58.816L411.755 752.64l457.088-457.088-58.838-58.816-398.25 398.25z' fill='%23fff'/%3E%3C/svg%3E");
}

.hnui-checkbox.disabled .hnui-checkbox-label,
.hnui-checkbox:not(.disabled) .hnui-checkbox-input:disabled + .hnui-checkbox-label,
fieldset:disabled .hnui-checkbox .hnui-checkbox-label {
  cursor: not-allowed;
  pointer-events: none;
  color: var(--hnui-disabled-color);
}

.hnui-checkbox.disabled .hnui-checkbox-label .hnui-checkbox-input,
.hnui-checkbox.disabled .hnui-checkbox-input:not(:disabled),
.hnui-checkbox:not(.disabled) .hnui-checkbox-input:disabled,
fieldset:disabled .hnui-checkbox:not(.disabled) .hnui-checkbox-input:not(:disabled) {
  background-color: var(--hnui-disabled-bg-color);
  border-color: var(--hnui-border-color);
  pointer-events: none;
  cursor: not-allowed;
}

.hnui-checkbox-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.hnui-checkbox.hnui-checkbox-box {
  --hnui-label-padding-x: 30px;
  --hnui-label-padding-x-r: 11px;
  --hnui-label-padding-y: 5px;

  position: relative;
  margin: 0;
  padding: 0;
  /* box-sizing: content-box; */
}

.hnui-checkbox.hnui-checkbox-box.hnui-checkbox-sm {
  --hnui-label-padding-x: 28px;
  --hnui-label-padding-x-r: 8px;
  --hnui-label-padding-y: 0px;
}

.hnui-checkbox.hnui-checkbox-box.hnui-checkbox-lg {
  --hnui-label-padding-x: 36px;
  --hnui-label-padding-x-r: 16px;
  --hnui-label-padding-y: 8px;
}

.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-label {
  position: inherit;
  z-index: 0;
  padding-top: var(--hnui-label-padding-y);
  padding-bottom: var(--hnui-label-padding-y);
  padding-left: var(--hnui-label-padding-x);
  padding-right: var(--hnui-label-padding-x-r);
  border-radius: 3px;
  border: var(--hnui-border-width) solid var(--hnui-border-color);
  /* box-sizing: content-box; */
}

.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-input {
  position: absolute;
  left: var(--hnui-label-padding-x);
  z-index: 1;
}

.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-label.checked.hnui-checkbox-label,
.hnui-checkbox.hnui-checkbox-box.checked.hnui-checkbox-box .hnui-checkbox-label,
.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-input:checked.hnui-checkbox-input + .hnui-checkbox-label {
  border: var(--hnui-border-width) solid var(--hnui-brand-color-normal);
}

.hnui-checkbox.hnui-checkbox-box.hover:not(.disabled) .hnui-checkbox-label,
.hnui-checkbox.hnui-checkbox-box:hover:not(.disabled) .hnui-checkbox-label,
.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-input:not(:disabled) + .hnui-checkbox-label.hover,
.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-input:not(:disabled) + .hnui-checkbox-label:hover {
  border-color: var(--hnui-brand-color-normal);
}

.hnui-checkbox.hnui-checkbox-box.checked.hnui-checkbox-box .hnui-checkbox-label {
  pointer-events: none;
}

.hnui-checkbox.hnui-checkbox-box .hnui-checkbox-input:disabled:checked + .hnui-checkbox-label {
  border-color: var(--hnui-brand-color-disabled-border);
}

.hnui-checkbox-group {
  display: inline-block;
  white-space: nowrap;
}

.hnui-checkbox-group.disabled {
  opacity: 0.36;
}
.hnui-checkbox-group.disabled.hnui-checkbox-group input,
.hnui-checkbox-group.disabled.hnui-checkbox-group label {
  pointer-events: none;
}

.hnui-checkbox-group .hnui-checkbox-label {
  --hnui-label-padding-x: 22px;
  --hnui-label-padding-y: 5px;

  display: inline-flex;
  align-items: center;
  position: relative;
  z-index: 0;
  line-height: var(--hnui-label-padding-x);
  padding: var(--hnui-label-padding-y) var(--hnui-label-padding-x);
  border: var(--hnui-border-width) solid var(--hnui-border-color);
  border-radius: 3px;
  background-color: transparent;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  transition: color 0.16s ease-in-out, background-color 0.16s ease-in-out, border-color 0.16s ease-in-out, box-shadow 0.16s ease-in-out;
}

.hnui-checkbox-group.hnui-checkbox-sm .hnui-checkbox-label {
  --hnui-label-padding-x: 22px;
  --hnui-label-padding-y: 1px;
  font-size: 12px;
}

.hnui-checkbox-group.hnui-checkbox-lg .hnui-checkbox-label {
  --hnui-label-padding-x: 22px;
  --hnui-label-padding-y: 9px;
  font-size: 16px;
}

.hnui-checkbox.hnui-checkbox-sm {
  font-size: 12px;
}

.hnui-checkbox.hnui-checkbox-lg {
  font-size: 16px;
}

.hnui-checkbox-group .hnui-checkbox-input:not(:disabled) + .hnui-checkbox-label.hover,
.hnui-checkbox-group .hnui-checkbox-input:not(:disabled) + .hnui-checkbox-label:hover {
  color: var(--hnui-brand-color-normal);
}

.hnui-checkbox-group .hnui-checkbox-input {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

.hnui-checkbox-group .hnui-checkbox-label.checked.hnui-checkbox-label,
.hnui-checkbox-group .hnui-checkbox-input:checked.hnui-checkbox-input + .hnui-checkbox-label {
  background: var(--hnui-brand-color-normal);
  border-color: var(--hnui-brand-color-normal);
  color: #fff;
  z-index: 1;
  border-left: 1px solid #ffffff2b;
}

.hnui-checkbox-group.hnui-checkbox-outline .hnui-checkbox-label.checked,
.hnui-checkbox-group .hnui-checkbox-input:checked + .hnui-checkbox-label.hnui-checkbox-outline,
.hnui-checkbox-group.hnui-checkbox-outline .hnui-checkbox-input:checked + .hnui-checkbox-label {
  background: transparent;
  border-color: var(--hnui-brand-color-normal);
  color: var(--hnui-brand-color-active);
}

.hnui-checkbox-group > .hnui-checkbox-group:not(:last-child) > .hnui-checkbox-label,
.hnui-checkbox-group > .hnui-checkbox-label.dropdown-toggle-split:first-child,
.hnui-checkbox-group > .hnui-checkbox-label:not(:last-child):not(.dropdown-toggle) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.hnui-checkbox-group > .hnui-checkbox-group:not(:first-child),
.hnui-checkbox-group > :not(.hnui-checkbox-input:first-child) + .hnui-checkbox-label {
  margin-left: calc(var(--hnui-border-width) * -1);
}

.hnui-checkbox-group > .hnui-checkbox-group:not(:first-child) > .hnui-checkbox-label,
.hnui-checkbox-group > .hnui-checkbox-label:nth-child(n + 3),
.hnui-checkbox-group > :not(.hnui-checkbox-input) + .hnui-checkbox-label {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.hnui-checkbox-group .hnui-checkbox-input:disabled:not(:checked) + .hnui-checkbox-label {
  color: var(--hnui-disabled-color);
  cursor: not-allowed;
  pointer-events: none;
}

.hnui-checkbox-group .hnui-checkbox-input:disabled:checked + .hnui-checkbox-label {
  cursor: not-allowed;
  pointer-events: none;
  color: var(--hnui-brand-color-disabled-border);
  background: var(--hnui-brand-color-disabled-bg);
  border-color: var(--hnui-brand-color-disabled-border);
}
.hnui-checkbox-group.hnui-checkbox-outline .hnui-checkbox-input:disabled:checked + .hnui-checkbox-label {
  background: transparent;
}

.hnui-checkbox-group.hnui-checkbox-filled {
  background: var(--hnui-info-bg);
  border-radius: 3px;
}
.hnui-checkbox-group.hnui-checkbox-filled .hnui-checkbox-label {
  background: var(--hnui-info-bg);
  border-color: var(--hnui-info-bg);
}

.hnui-checkbox-group.hnui-checkbox-filled.hnui-checkbox-group .hnui-checkbox-label {
  --ctp-border-width: 2px;

  --hnui-label-padding-f-x: calc(var(--hnui-label-padding-x) - var(--ctp-border-width) / 2);
  --hnui-label-padding-f-y: calc(var(--hnui-label-padding-y) - var(--ctp-border-width) / 2);

  position: relative;
  border-width: var(--ctp-border-width);
  border-left-width: var(--ctp-border-width) !important;
  padding: var(--hnui-label-padding-f-y) var(--hnui-label-padding-f-x);
}
.hnui-checkbox-group.hnui-checkbox-filled.hnui-checkbox-group .hnui-checkbox-label.hover,
.hnui-checkbox-group.hnui-checkbox-filled.hnui-checkbox-group .hnui-checkbox-label:hover {
  color: var(--hnui-color-black);
}

.hnui-checkbox-group.hnui-checkbox-filled .hnui-checkbox-label.checked,
.hnui-checkbox-group.hnui-checkbox-filled .hnui-checkbox-input:checked + .hnui-checkbox-label {
  background: var(--hnui-color-white);
  border-color: var(--hnui-info-bg);
  border-radius: 5px;
  color: var(--hnui-neutral-color-2);
}

基础多选

默认选中,在<input type="checkbox">上设置checked属性;多选组合,相同name的值为一组选项,如:name="fieldName"

Base
Box
Button
Outline
Filled
html
<div class="hnui-checkbox">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName" id="checkbox1" value="1" />
  <label class="hnui-checkbox-label" for="checkbox1">未选中</label>
</div>
<div class="hnui-checkbox">
  <input class="hnui-checkbox-input indeterminate" type="checkbox" name="fieldName" id="checkbox2" value="1" />
  <label class="hnui-checkbox-label" for="checkbox2">半选中</label>
</div>
<div class="hnui-checkbox">
  <!-- input type="checkbox" 放在 label标签内 -->
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input indeterminate" name="fieldName" value="2" />
    半选中2
  </label>
</div>
<div class="hnui-checkbox">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldName" value="3" checked />
    已选中
  </label>
</div>
html
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName" id="checkbox_box1" value="1" />
  <label class="hnui-checkbox-label" for="checkbox_box1">未选中</label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input indeterminate" type="checkbox" name="fieldName" id="checkbox_box2" value="2" />
  <label class="hnui-checkbox-label" for="checkbox_box2">半选中</label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <!-- input type="checkbox" 放在 label标签内 -->
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input indeterminate" name="fieldName" value="3" />
    半选中2
  </label>
</div>
<div class="hnui-checkbox hnui-checkbox-box checked">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldName" value="4" checked />
    已选中
  </label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName" id="checkbox_box5" value="5" checked />
  <label class="hnui-checkbox-label" for="checkbox_box5">已选中</label>
</div>
html
<div class="hnui-checkbox-group">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName2" value="1" id="checkbox_button1" />
  <label class="hnui-checkbox-label" for="checkbox_button1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName2" value="2" id="checkbox_button2" checked />
  <label class="hnui-checkbox-label" for="checkbox_button2">选项二</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName2" value="3" id="checkbox_button3" />
  <label class="hnui-checkbox-label" for="checkbox_button3">选项三</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName2" value="4" id="checkbox_button4" />
  <label class="hnui-checkbox-label" for="checkbox_button4">选项四</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-outline">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName3" value="1" id="checkbox_outline1" />
  <label class="hnui-checkbox-label" for="checkbox_outline1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName3" value="2" id="checkbox_outline2" checked />
  <label class="hnui-checkbox-label" for="checkbox_outline2">选项二</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName3" value="3" id="checkbox_outline3" />
  <label class="hnui-checkbox-label" for="checkbox_outline3">选项三</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName3" value="4" id="checkbox_outline4" />
  <label class="hnui-checkbox-label" for="checkbox_outline4">选项四</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-filled">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName4" value="1" id="checkbox_filled1" />
  <label class="hnui-checkbox-label" for="checkbox_filled1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName4" value="2" id="checkbox_filled2" checked />
  <label class="hnui-checkbox-label" for="checkbox_filled2">选项二</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName4" value="3" id="checkbox_filled3" />
  <label class="hnui-checkbox-label" for="checkbox_filled3">选项三</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldName4" value="4" id="checkbox_filled4" />
  <label class="hnui-checkbox-label" for="checkbox_filled4">选项四</label>
</div>
html
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName" id="checkbox_box1" value="1" />
  <label class="hnui-checkbox-label" for="checkbox_box1">未选中</label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input indeterminate" type="checkbox" name="fieldName" id="checkbox_box2" value="2" />
  <label class="hnui-checkbox-label" for="checkbox_box2">半选中</label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <!-- input type="checkbox" 放在 label标签内 -->
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input indeterminate" name="fieldName" value="3" />
    半选中2
  </label>
</div>
<div class="hnui-checkbox hnui-checkbox-box checked">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldName" value="4" checked />
    已选中
  </label>
</div>
<div class="hnui-checkbox hnui-checkbox-box">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldName" id="checkbox_box5" value="5" checked />
  <label class="hnui-checkbox-label" for="checkbox_box5">已选中</label>
</div>

多选状态

Base
Box
Button
Outline
Filled
Disabled
html
<div class="hnui-checkbox">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusBase" id="checkboxStatus1" value="1" />
  <label class="hnui-checkbox-label" for="checkboxStatus1">未选择</label>
</div>
<div class="hnui-checkbox hover">
  <!-- input type="checkbox" 放在 label标签内 -->
  <label class="hnui-checkbox-label hover">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldNameStatusBase" value="2" />
    悬停
  </label>
</div>
<div class="hnui-checkbox">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldNameStatusBase" value="2" checked />
    选中
  </label>
</div>
<div class="hnui-checkbox">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusBase" id="fieldNameDisabled1" disabled value="1" />
  <label class="hnui-checkbox-label" for="fieldNameDisabled1">未选禁用</label>
</div>
<div class="hnui-checkbox disabled">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input" name="fieldNameStatusBase" disabled checked value="2" />
    选中禁用
  </label>
</div>
<div class="hnui-checkbox">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input indeterminate" name="fieldNameStatusBase" value="2" />
    半选
  </label>
</div>
<div class="hnui-checkbox disabled">
  <label class="hnui-checkbox-label">
    <input type="checkbox" class="hnui-checkbox-input indeterminate" name="fieldNameStatusBase" value="2" disabled />
    半选禁用
  </label>
</div>
html
<div class="hnui-checkbox-group">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusButton" value="1" id="checkboxStatus_button1" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button1">未选择</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusButton" value="2" id="checkboxStatus_button2" />
  <label class="hnui-checkbox-label hover" for="checkboxStatus_button2">悬停</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusButton" checked value="3" id="checkboxStatus_button3" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button3">选中</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameDisabled2" disabled value="4" id="checkboxStatus_button4" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button4">未选禁用</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameDisabled2" disabled checked value="5" id="checkboxStatus_button5" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button5">选中禁用</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-outline">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusOutline" value="1" id="checkboxStatus_outline1" />
  <label class="hnui-checkbox-label" for="checkboxStatus_outline1">未选择</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusOutline" value="2" id="checkboxStatus_outline2" />
  <label class="hnui-checkbox-label hover" for="checkboxStatus_outline2">悬停</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusOutline" checked value="3" id="checkboxStatus_outline3" />
  <label class="hnui-checkbox-label" for="checkboxStatus_outline3">选中</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameOutlineDisabled3" disabled value="4" id="checkboxStatus_outline4" />
  <label class="hnui-checkbox-label" for="checkboxStatus_outline4">未选禁用</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameOutlineDisabled3" disabled checked value="4" id="checkboxStatus_outline5" />
  <label class="hnui-checkbox-label" for="checkboxStatus_outline5">选中禁用</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-filled">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusFilled" value="1" id="checkboxStatus_filled1" />
  <label class="hnui-checkbox-label" for="checkboxStatus_filled1">未选择</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusFilled" value="2" id="checkboxStatus_filled2" />
  <label class="hnui-checkbox-label hover" for="checkboxStatus_filled2">悬停</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameStatusFilled" value="3" id="checkboxStatus_filled3" />
  <label class="hnui-checkbox-label" for="checkboxStatus_filled3">选中</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusFilled" value="4" id="checkboxStatus_filled4" />
  <label class="hnui-checkbox-label" for="checkboxStatus_filled4">未选禁用</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameDisabled3" disabled checked value="4" id="checkboxStatus_outline5" />
  <label class="hnui-checkbox-label" for="checkboxStatus_outline5">选中禁用</label>
</div>
html
<div class="hnui-checkbox-group disabled">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusDisabled" value="1" id="checkboxStatus_button1" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button1">未选择</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusDisabled" value="2" id="checkboxStatus_button2" />
  <label class="hnui-checkbox-label hover" for="checkboxStatus_button2">悬停</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusDisabled" checked value="3" id="checkboxStatus_button3" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button3">选中</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusDisabled2" value="4" id="checkboxStatus_button4" />
  <label class="hnui-checkbox-label" for="checkboxStatus_button4">未选禁用</label>

  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameStatusDisabled2" checked value="5" id="checkboxStatus_button5" />
  <label class="hnui-checkbox-label hnui-checkbox-outline" for="checkboxStatus_button5">选中禁用</label>
</div>

多选尺寸

Base
Box
Button
Outline
Filled
html
<div class="docs-demo-items">
  <div class="hnui-checkbox hnui-checkbox-sm">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBaseSmall" id="checkboxSizeBase_small1" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBase_small1">选项一</label>
  </div>
  <div class="hnui-checkbox hnui-checkbox-sm">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBaseSmall" value="2" />
      选项二
    </label>
  </div>
</div>
<div class="docs-demo-items">
  <div class="hnui-checkbox">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBaseDefault" id="checkboxSizeBase2" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBase2">选项一</label>
  </div>
  <div class="hnui-checkbox">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBaseDefault" value="2" />
      选项二
    </label>
  </div>
</div>
<div class="docs-demo-items">
  <div class="hnui-checkbox hnui-checkbox-lg">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBaseLarge" id="checkboxSizeBase_large1" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBase_large1">选项一</label>
  </div>
  <div class="hnui-checkbox hnui-checkbox-lg">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBaseLarge" value="2" />
      选项二
    </label>
  </div>
</div>
html
<div class="docs-demo-items docs-demo-items-sm">
  <div class="hnui-checkbox hnui-checkbox-box hnui-checkbox-sm">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBoxSmall" id="checkboxSizeBox_small1" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBox_small1">选项一</label>
  </div>
  <div class="hnui-checkbox hnui-checkbox-box hnui-checkbox-sm">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBoxSmall" value="2" />
      选项二
    </label>
  </div>
</div>
<div class="docs-demo-items docs-demo-items-sm">
  <div class="hnui-checkbox hnui-checkbox-box">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBoxDefault" id="checkboxSizeBox2" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBox2">选项一</label>
  </div>
  <div class="hnui-checkbox hnui-checkbox-box">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBoxDefault" value="2" />
      选项二
    </label>
  </div>
</div>
<div class="docs-demo-items docs-demo-items-sm">
  <div class="hnui-checkbox hnui-checkbox-box hnui-checkbox-lg">
    <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeBoxLarge" id="checkboxSizeBox_large1" value="1" />
    <label class="hnui-checkbox-label" for="checkboxSizeBox_large1">选项一</label>
  </div>
  <div class="hnui-checkbox hnui-checkbox-box hnui-checkbox-lg">
    <!-- input type="checkbox" 放在 label标签内 -->
    <label class="hnui-checkbox-label">
      <input type="checkbox" class="hnui-checkbox-input" checked name="fieldNameSizeBoxLarge" value="2" />
      选项二
    </label>
  </div>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-sm">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeButtonSmall" value="1" id="checkboxSize_button_small1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_small1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeButtonSmall" value="2" id="checkboxSize_button_small2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_small2">选项二</label>
</div>

<div class="hnui-checkbox-group">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeButtonDefault" value="1" id="checkboxSize_button1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeButtonDefault" value="2" id="checkboxSize_button2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button2">选项二</label>
</div>

<div class="hnui-checkbox-group hnui-checkbox-lg">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeButtonLarge" value="1" id="checkboxSize_button_large1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_large1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeButtonLarge" value="2" id="checkboxSize_button_large2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_large2">选项二</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-outline hnui-checkbox-sm">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeOutlineSmall" value="1" id="checkboxSize_outline_small1" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline_small1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeOutlineSmall" value="2" id="checkboxSize_outline_small2" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline_small2">选项二</label>
</div>

<div class="hnui-checkbox-group hnui-checkbox-outline">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeOutline" value="1" id="checkboxSize_outline1" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeOutline" value="2" id="checkboxSize_outline2" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline2">选项二</label>
</div>

<div class="hnui-checkbox-group hnui-checkbox-outline hnui-checkbox-lg">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeOutlineLarge" value="1" id="checkboxSize_outline_large1" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline_large1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeOutlineLarge" value="2" id="checkboxSize_outline_large2" />
  <label class="hnui-checkbox-label" for="checkboxSize_outline_large2">选项二</label>
</div>
html
<div class="hnui-checkbox-group hnui-checkbox-filled hnui-checkbox-sm">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeFilledSmall" value="1" id="checkboxSize_button_filled_small1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled_small1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeFilledSmall" value="2" id="checkboxSize_button_filled_small2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled_small2">选项二</label>
</div>

<div class="hnui-checkbox-group hnui-checkbox-filled">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeFilledDefault" value="1" id="checkboxSize_button_filled1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeFilledDefault" value="2" id="checkboxSize_button_filled2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled2">选项二</label>
</div>

<div class="hnui-checkbox-group hnui-checkbox-filled hnui-checkbox-lg">
  <input class="hnui-checkbox-input" type="checkbox" name="fieldNameSizeFilledLarge" value="1" id="checkboxSize_button_filled_large1" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled_large1">选项一</label>

  <input class="hnui-checkbox-input" type="checkbox" checked name="fieldNameSizeFilledLarge" value="2" id="checkboxSize_button_filled_large2" />
  <label class="hnui-checkbox-label" for="checkboxSize_button_filled_large2">选项二</label>
</div>

统一UI