Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

A proof of concept: Add responsive support for @emotion/native. It supports both React Native (Expo) and React Native Web (Expo for Web), as well as server-side rendering with frameworks such as Next.js.

License

Notifications You must be signed in to change notification settings

hesyifei/emotion-native-media-query

Repository files navigation

emotion-native-media-query

Add responsive support for @emotion/native. It supports both React Native (Expo) and React Native Web (Expo for Web), as well as server-side rendering with frameworks such as Next.js.

NPM Build Status

Install

npm install --save emotion-native-media-query

Usage

import * as React from "react";
import RView, { MediaRule } from "emotion-native-media-query";

class Example extends React.Component {
  render() {
    return (
      <RView
        style={{
          backgroundColor: "black",
        }}
        rStyle={{
          [MediaRule.MaxWidth]: {
            300: {
              backgroundColor: "red",
            },
            600: {
              backgroundColor: "green",
            },
            900: {
              backgroundColor: "blue",
            },
          },
          [MediaRule.MinWidth]: {
            200: {
              padding: 33,
            },
            500: {
              padding: 66,
            },
            800: {
              padding: 99,
            },
          },
        }}
      />
    );
  }
}

For more, read the API Reference for RView.

License

MIT © hesyifei

About

A proof of concept: Add responsive support for @emotion/native. It supports both React Native (Expo) and React Native Web (Expo for Web), as well as server-side rendering with frameworks such as Next.js.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published