2.0.8 • Published 5 months ago

react-device-display v2.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

React Device Display

react-device-display is a library that provides components to simulate the appearance of devices like iPhones and Macbooks in a React application.

Installation

You can install react-device-display using npm:

npm install react-device-display

Usage

Mac component

The Mac component simulates the appearance of a Macbook. It accepts the following props:

PropTypeDefaultDescription
openbooleantrueWhether the Macbook is open or closed
widthnumber600The width of the Macbook in pixels
startupbooleanfalseWhether to show a startup animation
animateOpenbooleanfalseWhether to animate the opening/closing of the Macbook
openAnglenumber (degrees)0The angle at which the Macbook opens (0 for fully flat, 90 for fully open)
childrenReact.ReactNodeThe content to display on the Macbook screen

Here's an example usage of the Mac component:

import { Mac } from 'react-device-display';

function App() {
  return (
    <Mac open={true} width={800} animateOpen={true} startup={true}>
      <h1>Hello, World!</h1>
    </Mac>
  );
}

Iphone component

The Iphone component simulates the appearance of an iPhone. It accepts the following props:

PropTypeDefaultDescription
widthnumber400The width of the iPhone in pixels
childrenReact.ReactNodeThe content to display on the iPhone screen (e.g. a mobile website)

Here's an example usage of the Iphone component:

import { Iphone } from 'react-device-display';

function App() {
  return (
    <Iphone width={400}>
      <h1>Hello, World!</h1>
    </Iphone>
  );
}

License

This library is licensed under the MIT License.