New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opensea/react-media

Package Overview
Dependencies
Maintainers
9
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opensea/react-media

Javascript library to deal with media queries in isomorphic React applications.

  • 1.0.5
  • npm
  • Socket score

Version published
Weekly downloads
196
decreased by-14.41%
Maintainers
9
Weekly downloads
 
Created
Source

react-media

Coverage Status styled with prettier

@opensea/react-media is a Javascript library to deal with media queries in isomorphic React applications.

Its heavily inspired by https://github.com/artsy/fresnel but is compatible with React 18.

Installation

npm

npm i @opensea/react-media

yarn

yarn add @opensea/react-media

Usage

// media.ts

import { createMedia } from '@opensea/react-media';

const { createMediaStyle, Media, SizeProvider } = createMedia({
  sm: 640,
  md: 768,
  lg: 1024,
  xl: 1280,
  '2xl': 1536,
  container: 1600,
  '3xl': 1910
});

export const mediaStyle = createMediaStyle();
// ComponentX.react.tsx

export function ComponentX() {
  return <Media greaterThan="md">Render if greater than md</Media>;
}

NextJS

// __app.tsx

import React from 'react';
import { SizeProvider } from './media';
import type { AppProps } from 'next/app';

export default function App({ Component, pageProps }: AppProps) {
  return (
    <SizeProvider>
      <Component {...pageProps} />
    </SizeProvider>
  );
}
// _document.tsx

import { Html, Head, Main, NextScript } from 'next/document';
import { mediaStyles } from './media';

export default function Document() {
  return (
    <Html>
      <Head>
        <style
          dangerouslySetInnerHTML={{ __html: mediaStyles }}
          type="text/css"
        />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  );
}

FAQs

Package last updated on 06 Apr 2023

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