Open terrymun opened 2 months ago
There are several Radix UI Primitives that rely on dangerouslySetInnerHtml to inject content into <style> tags, for example the <ScrollArea> (see code) and <Select> (see code) components.
dangerouslySetInnerHtml
<style>
<ScrollArea>
<Select>
This causes issues in React apps that has set trusted types in their CSP headers.
p/s: Not all browsers support the trusted types CSP header yet.
Using these components should not cause warnings in browsers that support trusted types CSP headers serving a React App with such headers set.
@radix-ui/react-scroll-area
@radix-ui/react-select
Hi,
I opened a discussion on improving Radix's style authoring to fix these CSP issues. Perhaps we can get more buy-in via more engagement: https://github.com/radix-ui/primitives/discussions/3130
Bug report
Current Behavior
There are several Radix UI Primitives that rely on
dangerouslySetInnerHtml
to inject content into<style>
tags, for example the<ScrollArea>
(see code) and<Select>
(see code) components.This causes issues in React apps that has set trusted types in their CSP headers.
p/s: Not all browsers support the trusted types CSP header yet.
Expected behavior
Using these components should not cause warnings in browsers that support trusted types CSP headers serving a React App with such headers set.
Suggested solution
dangerouslySetInnerHtml
to set inline stylesYour environment
@radix-ui/react-scroll-area
,@radix-ui/react-select