Hit slop
A 16px button looks precise, but a 16px target is easy to miss. Keep its visible size and give it a 24px hit area with a pseudo-element.
12345{ "rules": { "systomic/hit-slop": "warn" }}See the difference
className="size-4 rounded-full"className="relative size-4 rounded-full after:absolute after:-inset-1"What doesn't work
Oxlint
3 findings123456789101112131415161718192021import { Dialog } from "radix-ui";
export function CloseButton() { return ( <Dialog.Close className="size-4 text-gray-500"> <span className="sr-only">Close</span> </Dialog.Close> );}
export function ColorKnob({ onPointerDown }: { onPointerDown: () => void }) { return ( <div role="slider" aria-valuenow={50} className="absolute size-3 rounded-full" onPointerDown={onPointerDown} /> );}
export function RemoveTag() { return ( <button type="button" aria-label="Remove" style={{ width: 14, height: 14 }} /> );}systomic/hit-slop <Dialog.Close> is 16×16px: too small to hit reliably. Extend its hit area to 24px with a pseudo-element, without changing how it looks: relative after:absolute after:-inset-1.
systomic/hit-slop <div> is 12×12px: too small to hit reliably. Extend its hit area to 24px with a pseudo-element, without changing how it looks: after:absolute after:-inset-1.5.
systomic/hit-slop <button> is 14×14px: too small to hit reliably. Extend its hit area to 24px with a pseudo-element, without changing how it looks: relative after:absolute after:-inset-1.5.
Stylelint
1 finding12345.color-knob { position: absolute; width: 12px; height: 12px;}systomic/hit-slop .color-knob is 12×12px: too small to hit reliably. Extend its hit area to 24px with a pseudo-element, without changing how it looks: .color-knob::after { content: ""; position: absolute; inset: -6px; }.
What works
No findingsOxlint
123456789101112131415161718192021222324252627282930import { Dialog } from "radix-ui";
/** 16px visible, 24px to hit. */export function CloseButton() { return ( <Dialog.Close className="relative size-4 text-gray-500 after:absolute after:-inset-1"> <span className="sr-only">Close</span> </Dialog.Close> );}
export function ColorKnob({ onPointerDown }: { onPointerDown: () => void }) { return ( <div role="slider" aria-valuenow={50} className="absolute size-3 rounded-full after:absolute after:-inset-1.5" onPointerDown={onPointerDown} /> );}
/** Inline links and buttons without a fixed size grow with their text. */export function Terms() { return ( <a href="/terms" className="underline"> Terms </a> );}Stylelint
1234567891011.color-knob { position: absolute; width: 12px; height: 12px;}
.color-knob::after { content: ""; position: absolute; inset: -6px;}Details
A 12px knob looks precise, but a 12px hit target is hard to hit. Small buttons, links and controls keep their visible size and get a larger hit area from an absolutely positioned pseudo-element with a negative inset. By default the hit area must be at least 24×24px (WCAG 2.5.8, Target Size).
12<button className="size-4" /> // reported<button className="relative size-4 after:absolute after:-inset-1" /> // 16px visible, 24px to hit
<button>is 16×16px: too small to hit reliably. Extend its hit area to 24px with a pseudo-element, without changing how it looks:relative after:absolute after:-inset-1.
The suggestion appends those classes to a plain className string. It uses before: when after: is already in use, and leaves out relative when the element is already positioned. For StyleX it names the "::after" object (content: "''", position: "absolute", inset: -6).
What is checked
- Interactive elements:
button,a,input,select,summary;role="button","link","slider","switch","checkbox","tab","menuitem", …; elements withonClick,onPointerDown,onMouseDownoronTouchStart; components named like controls (IconButton,Dialog.Close,Slider.Thumb,…Trigger,…Toggle,…Knob,…Handle); names incomponents. - Size:
size-*,w-*,h-*,width/heightin inline styles and StyleX. Without a known size, nothing is reported. Inline text links and buttons with padding grow with their content. - Hit area: an
after:/before:pseudo-element withabsoluteand negative insets (-inset-1,-inset-x-2,inset-[-4px]) or its own size. Classes in StyleX’s"::after"work the same way. - Custom hit area classes: utilities that grow the hit area on their own, like a Tailwind v4
@utility touch-hitbox. See below.
Also reported:
- a hit area that is still under the minimum (
size-3 after:-inset-1reaches only 20px), - a hit area on an element that isn’t positioned: the pseudo-element is then placed against another ancestor. The suggestion adds
relative.
Not reported: aria-hidden="true" elements, <input type="hidden">, variants (md:size-4), decorative parts (Checkbox.Indicator, CheckboxIndicator, Select.Icon), and thumbs or controls inside their own root (Switch.Thumb in Switch.Root, SwitchThumb in Switch, Checkbox.Control): the root is the hit target. Other parts (Checkbox.Root in Checkbox.Group, ToggleGroup.Toggle), thumbs other than a switch’s (Slider.Thumb, dragged on its own), controls inside other controls, and what asChild or render puts in place of a control or trigger (even a Switch.Thumb given to <Switch.Root asChild>) are still checked.
Custom hit area classes
A design system often wraps the pseudo-element in one utility:
12345678@utility touch-hitbox { position: relative; &::after { content: ""; position: absolute; inset: -8px; }}1<button className="size-4 touch-hitbox" /> // 16px visible, 32px to hitWhen the stylesheet that defines it is imported by the file or listed in settings.systomic.stylesheets (see styling), the rule reads the utility: its ::after / ::before declarations and @apply’d utilities count like after: classes, and its position positions the element. Plain classes (.tap-target::after { … }) work the same way. Declarations and @apply count in source order, and a selector list (.hit::after, .hit::before) counts for each pseudo-element. Rules inside @media and other states don’t count. In classes, StyleX and stylesheets alike, a pseudo-element with pointer-events: none (after:pointer-events-none) is decoration and doesn’t count as a hit area.
When the stylesheet isn’t available to the linter, name the classes and how many px they add on each side:
1"systomic/hit-slop": ["warn", { "hitAreaClasses": { "touch-hitbox": 8 } }]Such a class takes a free pseudo-element and positions the element. With a variant (md:touch-hitbox) it doesn’t count. In Stylelint, hitAreaClasses also counts for @apply touch-hitbox.
CSS (Stylelint)
Rules whose selector names a control (button, a, [role=slider], .icon-button, .color-knob, .close, …) with width / height under the minimum need a ::after / ::before rule in the same stylesheet, including nesting (&::after) and @apply.
12.color-knob { position: absolute; width: 12px; height: 12px; }.color-knob::after { content: ""; position: absolute; inset: -6px; }| Option | Default |
|---|---|
minSize |
24: smallest hit area in px, both ways |
spacing |
4: px per spacing step |
components |
[]: extra component names that are controls (Oxlint) |
hitAreaClasses |
{}: custom utilities that grow the hit area, class → px added on each side ({ "touch-hitbox": 8 }) |
ignore |
[]: file globs relative to the nearest package.json (Oxlint only); see monorepos |
attributes, callees, styleAttributes |
see styling |