Code
Highlight
Add interactive highlights to your PDFs with smooth navigation and clickable annotations
Loading...
Basic Usage
At its core, the PDF Highlight Layer lets you highlight sections of a PDF and navigate between them:
Adding Interactive Highlights
To make highlights interactive, use the usePdfJump
hook. Here's a complete example:
Highlight Format
Highlights are defined using pixel coordinates:
Custom Styling
The HighlightLayer component accepts className props for custom styling:
Loading States
Add a loading state to improve user experience:
TypeScript Support
Full TypeScript support is included. Example type for highlight rectangles:
Best Practices
- Always provide fallback content with the
loader
prop - Use relative units (pixels) for highlight coordinates
- Handle errors when jumping to highlights
- Keep highlight areas within document bounds