Caprice LogoCaprice UI

Touch Hitbox

The touch hitbox utility for Tailwind CSS

Installation

npx shadcn@latest add @caprice/touch-hitbox

Usage

Import the utility into your global.css file:

global.css
@import "tailwindcss";
@import "@caprice-ui/tailwind/utility/touch-hitbox";

Add the utility classes to your markup / components:

example.tsx
<button type="button" class="touch-hitbox">
  <Icon size="size-4">
</button>

Additionally, you can use the pointer-coarse: variant to apply the expanded touch target only on touchscreen devices:

example.tsx
// [!code word:pointer-coarse:touch-hitbox]
<button type="button" class="pointer-coarse:touch-hitbox">
  <Icon size="size-4">
</button>