Theme · ui · 8K
Pixel snap
Keeps bitmap labels on whole device pixels: <PixelSnap /> (or the usePixelSnap ref) moves a centred label's text to the nearest whole pixel by trading up to half a pixel of padding, so the face never smears into gray at 1x.
Install
pnpm dlx shadcn@latest add @s7ui/pixel-snapExample
Shut Down
Without
Shut Down
With PixelSnap
At 1× (zoom in on a screenshot) the unsnapped label may start at x.5 and smear into gray; the snapped one moves its text to the nearest whole pixel. On a 2× screen both look the same.
Info
- Files:
- components/ui/pixel-snap.tsx
- Uses:
- —
- Packages:
- —