CSP Provider
The CSP Provider component allows you to configure a Content Security Policy (CSP) nonce for Base UI components that create inline<style> or <script> tags, ensuring compatibility with strict CSP environments.
Import
Usage
Wrap your application or specific component tree with theCSPProvider to apply CSP configuration:
Disabling style elements
If you want to prevent Base UI from creating inline<style> elements entirely, use the disableStyleElements prop:
disableStyleElements is enabled, you must provide styling through custom class names or other methods.
API Reference
Props
children
- Type:
React.ReactNode - Optional
nonce
- Type:
string - Optional
<style> and <script> tags created by Base UI components. This value should match the nonce specified in your Content Security Policy headers.
disableStyleElements
- Type:
boolean - Default:
false - Optional
<style> elements created by Base UI components should not be rendered. Instead, components must specify CSS styles via custom class names or other methods.