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.
12345{ "rules": { "systomic/interactive-select-none": "warn" }}See the difference
className="px-3 py-1.5"className="px-3 py-1.5 select-none"What doesn't work
2 findings1234567891011121314151617export function SaveButton() { return ( <button type="submit" className="rounded-md px-3 py-1.5"> Save </button> );}
export function Tabs({ onSelect }: { onSelect: (tab: string) => void }) { return ( <div role="tablist"> <div role="tab" className="px-3" onClick={() => onSelect("general")}> General </div> </div> );}systomic/interactive-select-none <button> is clickable but has no select-none. A double click or a drag across it selects its label.
systomic/interactive-select-none <div> is clickable but has no select-none. A double click or a drag across it selects its label.
What works
No findings12345678910111213141516171819202122232425262728293031323334export function SaveButton() { return ( <button type="submit" className="rounded-md px-3 py-1.5 select-none"> Save </button> );}
/** A deliberate choice counts: a button that shows a value people copy keeps `select-text`. */export function CopyableId({ id }: { id: string }) { return ( <button type="button" className="font-mono select-text"> {id} </button> );}
/** Inline styles count too. Links with `href` and text inputs keep their text selectable. */export function Footer({ onClose }: { onClose: () => void }) { return ( <footer> <a href="/terms">Terms</a> <input type="email" className="w-full" /> <span role="button" tabIndex={0} style={{ userSelect: "none" }} onClick={onClose}> Close </span> </footer> );}
/** Classes passed in from props may carry it. */export function Trigger({ className, ...props }: { className?: string }) { return <button type="button" className={className} {...props} />;}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.
12<button className="px-3 py-1.5">Save</button> // reported, fixed:<button className="px-3 py-1.5 select-none">Save</button>
<button>is clickable but has noselect-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,WebkitUserSelector"user-select", - StyleX:
userSelectinstylex.create, also inside conditions like":hover", - CSS:
user-selector-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>withouthrefbut withonClick, and any<a>with one of those roles,- any other element with
onClick, reported without an autofix.select-noneis inherited, so on a clickable card or table row it would also stop people from copying the content inside. Putselect-noneon the part that acts as a control, orselect-texton 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:
123456789/* globals.css */@layer base { button, [role="button"], [role="tab"], summary { user-select: none; }}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.
1"systomic/interactive-select-none": "off"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:
1"systomic/interactive-select-none": [true, { severity: "warning" }]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.