āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/sadmann7/diceui/utilities/hitbox ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
npx shadcn@latest add "https://diceui.com/r/hitbox"
```package-install
@radix-ui/react-slot class-variance-authority
```
</Step>
<Step>
Copy and paste the following code into your project.
<ComponentSource name="hitbox" />
</Step>
</Steps>
Import the component and wrap it around any element to extend its clickable area.
import { Hitbox } from "@/components/hitbox";
<Hitbox>
<Button>Click me</Button>
</Hitbox>
Control the size of the extended hitbox area.
<ComponentTabs name="hitbox-sizes-demo" />Control which sides of the element the hitbox extends to.
<ComponentTabs name="hitbox-positions-demo" />Control the border radius of the hitbox area.
<ComponentTabs name="hitbox-radii-demo" />Enable debug mode to visualize the hitbox area during development.
<ComponentTabs name="hitbox-debug-demo" />The main hitbox component that extends the clickable area of its child element.
<AutoTypeTable path="./types/docs/hitbox.ts" name="HitboxProps" />
The hitbox provides three predefined sizes:
sm: 8px extension - Minimal extension for elements that need slight touch area improvementdefault: 12px extension - Standard extension that helps most elements meet accessibility requirementslg: 16px extension - Generous extension for dense interfaces or critical interactive elementsYou can also use custom CSS values for precise control:
<Hitbox size="18px">
<Checkbox />
</Hitbox>
The Hitbox component improves accessibility by:
default size (12px) to reach 56px total targetdefault size (12px) to reach 60px total targetsm size (8px) to reach 56px total targetlg size (16px) for maximum accessibilityā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā