systomic

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.

  • 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).
  • StylelintThe same check runs on .css and .scss files through the Stylelint plugin.
  • Suggested fixSuggests a replacement your editor can apply. It changes how the UI looks or moves, so oxlint --fix leaves it to you.

See the difference

Before
className="size-4 rounded-full"
After
className="relative size-4 rounded-full after:absolute after:-inset-1"

What doesn't work

Oxlint

3 findings

Stylelint

1 finding

What works

No findings

Oxlint

Stylelint

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).

<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 with onClick, onPointerDown, onMouseDown or onTouchStart; components named like controls (IconButton, Dialog.Close, Slider.Thumb, …Trigger, …Toggle, …Knob, …Handle); names in components.
  • Size: size-*, w-*, h-*, width / height in 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 with absolute and 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-1 reaches 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:

When 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:

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.

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
Esc