Hitspace

Extend clickable areas with CSS while keeping content aligned.

Hitbox directions

Click inside a dashed outline, just outside the checkbox, to toggle it.

ClassWhat it does
hitboxAdds an absolutely positioned ::after to the control. Use it on a positioned element, such as a button with relative.
hitbox-4Extends all four edges by four Tailwind spacing units.
hitbox-top-4Extends only the top edge.
hitbox-bottom-4Extends only the bottom edge.
hitbox-left-4Extends only the left edge.
hitbox-right-4Extends only the right edge.
hitbox-y-4Extends both block edges, normally top and bottom.
hitbox-x-4Extends both inline edges, normally left and right.
hover:hitbox:bg-mutedApplies the hover color to the expanded surface, including the area outside the button.
hitbox-center-ySets vertical padding to center the contents when the top and bottom extensions differ.

Four spacing units equal 16px in the default Tailwind theme. Edge classes override axis classes, and axis classes override the all-sides value.

Installation

Install Hitspace in a project that uses Tailwind CSS 4.1 or later.

Import Hitspace after Tailwind in your main stylesheet.

Share dialog

Hover over any row to see its expanded hitbox. The last row extends into the dialog's default padding on the left, right, and bottom. Click the edge of any row to change its demo access.

Share agent