Gathering detailed insights and metrics for react-shadow-root
Gathering detailed insights and metrics for react-shadow-root
Gathering detailed insights and metrics for react-shadow-root
Gathering detailed insights and metrics for react-shadow-root
npm install react-shadow-root
Typescript
Module System
Node Version
NPM Version
JavaScript (91.67%)
CSS (7.28%)
HTML (1.04%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
74 Stars
64 Commits
9 Forks
2 Watchers
19 Branches
2 Contributors
Updated on Apr 17, 2025
Latest Version
6.2.0
Package Id
react-shadow-root@6.2.0
Unpacked Size
25.67 kB
Size
8.14 kB
File Count
8
NPM Version
7.23.0
Node Version
14.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
23
Lets you add a shadow root to React components allowing you to use the shadow DOM. This provides scoped CSS and includes support for constructable stylesheets.
npm install --save react-shadow-root
https://apearce.github.io/react-shadow-root/
1import React from 'react'; 2import ReactShadowRoot from 'react-shadow-root'; 3 4class ShadowCounter extends React.Component { 5 state = { cnt: 0 }; 6 7 increment = () => { 8 this.setState({ 9 cnt: this.state.cnt + 1 10 }); 11 } 12 13 render() { 14 const style = `span { 15 background-color: #333; 16 border-radius: 3px; 17 color: #fff; 18 padding: 1px 5px; 19 } 20 button { 21 background-color: #fff; 22 border: 1px solid currentColor; 23 border-radius: 3px; 24 color: #333; 25 cursor: pointer; 26 outline: 0; 27 } 28 button:active { 29 background-color: #333; 30 color: #fff; 31 }`; 32 33 return ( 34 <div> {/* The shadow root will be attached to this DIV */} 35 <ReactShadowRoot> 36 <style>{style}</style> 37 <span>{this.state.cnt}</span> <button onClick={this.increment}>Click Me</button> 38 </ReactShadowRoot> 39 </div> 40 ); 41 } 42}
When the shadow root is created on its parent element, all children are copied into the shadow DOM. Styles in the shadow DOM are automatically scoped. You can inspect the element to confirm. Slots work as expected; just be sure to add {this.props.children}
after the closing ReactShadowRoot
tag.
Name | Description |
---|---|
constructableStylesheetsSupported | A boolean telling you if constructable stylesheets are supported by the browser. |
constructibleStylesheetsSupported | An alias of constructableStylesheetsSupported using the 'correct' spelling. |
shadowRootSupported | A boolean telling you if attaching a shadow root is supported by the browser, not the element. |
Prop | Type | Values | Default | Description |
---|---|---|---|---|
declarative | Boolean | true or false | false | Creates a Declarative Shadow Root |
delegatesFocus | Boolean | true or false | false | Expands the focus behavior of elements within the shadow DOM. Click here for more information. |
mode | String | open or closed | open | Sets the mode of the shadow root. |
stylesheets | Array | arrayOf(CSSStyleSheet) | optional | Takes an array of CSSStyleSheet objects for constructable stylesheets. |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
67 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More