Skip to content

Checkbox Options Plugin

The checkbox-options plugin renders a checkbox next to each option in the dropdown, providing a visual indicator of selected state. This is especially useful for multiple-select elements.

Usage

Behavior

  • Each option in the dropdown displays a checkbox to its left (right in RTL mode)
  • Selected options show a checked checkbox
  • Clicking an option toggles the checkbox and the selection state
  • Works with data-close-on-select="false" to keep the dropdown open for multiple selections

TIP

Set data-close-on-select="false" when using checkbox-options so users can select multiple items without the dropdown closing after each click.

With Optgroups

Checkboxes work alongside optgroups:

Styling

Customize the checkbox appearance:

css
.dot-select .ds-option-checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid #cbd5e1;
  border-radius: 3px;
  margin-right: 8px;
  flex-shrink: 0;
}

.dot-select .ds-option-checkbox.checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

Accessibility

Each checkbox is rendered with the appropriate role="checkbox" and aria-checked attributes for screen reader compatibility.

MIT Licensed