MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / Highlight

Function Highlight

console/src/components/Highlight.tsx:72–94  ·  view source on GitHub ↗
(props: HighlightProps)

Source from the content-addressed store, hash-verified

70}
71
72const Highlight = (props: HighlightProps) => {
73 const { children, query, styles, caseSensitive } = props;
74
75 if (typeof children !== "string") {
76 throw new Error("The children prop of Highlight must be a string");
77 }
78
79 const chunks = useHighlight({ query, text: children, caseSensitive });
80
81 return (
82 <>
83 {chunks.map((chunk, index) =>
84 chunk.match ? (
85 <Mark key={index} sx={styles}>
86 {chunk.text}
87 </Mark>
88 ) : (
89 <Fragment key={index}>{chunk.text}</Fragment>
90 ),
91 )}
92 </>
93 );
94};
95
96export default Highlight;

Callers

nothing calls this directly

Calls 2

useHighlightFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected