Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-styled-shadow-dom

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-styled-shadow-dom

React shadow dom that works well with styled-components.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-styled-shadow-dom (demo)

React shadow DOM that works well with styled-components.

NPM Build Status JavaScript Style Guide

  • Uses react-shadow under the hood
  • Makes it really simple to use styled-somponents in shadow DOM
  • Useful for testing responsive layouts and ensuring isolation from the parent document

Install

npm install --save react-styled-shadow-dom

Usage

Normally, when you try to use react-shadow, CSS styles from styled-components and theming information won't propagate to the shadow DOM.

The following example shows how easy it is to include styled content inside of shadow DOM using react-styled-shadow-dom.

import React, { Component } from 'react'

import StyledShadow from 'react-styled-shadow-dom'
import styled, { ThemeProvider } from 'styled-components'

const InnerBox = styled.div`
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: red;
`

const Text = styled.h4`
  color: #fff;
`

export default () => (
  <ThemeProvider theme={{ mode: 'dark' }}>
    <StyledShadow
      style={{
        width: 320,
        margin: '0 auto'
      }}
    >
      <InnerBox>
        <Text>Hello iframe!</Text>
      </InnerBox>
    </StyledShadow>
  </ThemeProvider>
)

You can view the above demo live here.

This seems simple, but it's actually fairly involved. It requires the use of StyleSheetManager in order to properly propagate all styles from styled-components.

Props

PropertyTypeDefaultDescription
childrennodeRequiredIframe body content.
styleobject{ display: 'block', overflow: 'scroll', border: 0 }Override iframe styles. Useful for setting width and height of iframe content.
...restobjectAny other props will be passed onto react-frame-component.

License

MIT © hydrateio

Keywords

FAQs

Package last updated on 08 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc