The following sample code adds an outline and changes the background color of the highlighted element:
import { searchPlugin, OnHighlightKeyword } from '@react-pdf-viewer/search';
const searchPluginInstance = searchPlugin({
onHighlightKeyword: (props: OnHighlightKeyword) => {
props.highlightEle.style.outline = '2px dashed blue';
props.highlightEle.style.backgroundColor = 'rgba(0, 0, 0, .1)';
},
});
import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout';
import { OnHighlightKeyword } from '@react-pdf-viewer/search';
const defaultLayoutPluginInstance = defaultLayoutPlugin({
toolbarPlugin: {
searchPlugin: {
onHighlightKeyword: (props: OnHighlightKeyword) => {
},
},
},
});