Skip to main content

SanitizedHTML

Reference​

  • SanitizedHTML renders an HTML string after cleaning it with DOMPurify, so scripts and unsafe attributes are removed.
  • It is used for text that contains simple markup, for example a column title such as Device <br/> Classes that must show on two lines instead of showing the tag as text.
  • It renders a div. To get the same font and line height as the standard grid headers, wrap it in Text.

Props​

  1. html
    • Type: string
    • Required: Yes
    • Description: The HTML string to render.

Usage Example​

function Example() {
const { protrakComponents } = React.useContext(customWidgetContext);
const { Text, SanitizedHTML } = protrakComponents;

const category = 'Device <br/> Classes';

return (
<Text title={category.replace(/(<([^>]+)>)/gi, '')} style={{ fontWeight: 'bold' }}>
<SanitizedHTML html={category} />
</Text>
);
}