systomic

Interactive select none

Double-click a button or drag across a tab and its label turns blue, like text in a document. Native controls never do that. select-none keeps it a control.

  • RuleIn recommended.json: breaking it breaks the design-system contract.
  • WarningShows in the editor and in CI output, but doesn't fail the run (unless you pass --deny-warnings).
  • Autofixoxlint --fix fixes it for you.

See the difference

Before
className="px-3 py-1.5"
After
className="px-3 py-1.5 select-none"

What doesn't work

2 findings

What works

No findings

Details

A double click on a button, or a drag that starts on a tab, selects its label. Native apps never do that, and the blue highlight makes a control look like text. Clickable elements set select-none.

<button> is clickable but has no select-none. A double click or a drag across it selects its label.

The autofix appends select-none to a plain className string, or adds className="select-none" when there is none. Elements that spread props after it get no fix.

Every way to set it counts:

  • Tailwind and UnoCSS classes: select-none, with any variant,
  • inline styles: userSelect, WebkitUserSelect or "user-select",
  • StyleX: userSelect in stylex.create, also inside conditions like ":hover",
  • CSS: user-select or -webkit-user-select, and @apply select-none (Stylelint, see below).

Any select-* value is a decision: a button that shows an ID people copy keeps select-text, and that is not reported.

What counts as clickable

Intrinsic elements only (components set it where they render the element):

  • button, summary,
  • role="button", "tab", "checkbox", "radio", "switch", "slider", "menuitem", "option", …,
  • <a> without href but with onClick, and any <a> with one of those roles,
  • any other element with onClick, reported without an autofix. select-none is inherited, so on a clickable card or table row it would also stop people from copying the content inside. Put select-none on the part that acts as a control, or select-text on the element to keep its content copyable.

Not reported: elements with only onMouseDown, onPointerDown and the like (usually wrappers that stop propagation), links with href and role="link" (their text is content people copy), input, select and textarea, role="spinbutton", aria-hidden="true" elements, and elements whose classes come from props (className={cn("px-3", className)}, props.className) or that spread props after the class attribute, since those may carry it.

When not to use

Turn the rule off when user-select: none is already set globally for controls, for example in a base layer:

The rule can’t see a reset in another file, so it would report every button that already behaves correctly, and adding select-none to each of them only repeats the reset.

If the reset covers only some elements, keep the rule and skip the files it covers with ignore.

CSS (Stylelint)

Not in the Stylelint preset, for the same reason: a stylesheet can’t see a global reset in another file. Enable it when components are styled in CSS:

A stateless rule for a class that names a control (.icon-button, .tab-trigger, .color-knob) needs user-select in one of that class’s rules (:active and @apply select-none count). Link classes (.nav-link, .footerLink) are skipped like links in JSX, unless they also name a control (.link-button, .btn-link). The autofix adds -webkit-user-select: none and user-select: none: Safari needs the prefix.

Option Default
ignore []: file globs relative to the nearest package.json (Oxlint only); see monorepos
attributes, callees, styleAttributes see styling
Esc