react-device-mockup
v1.0.0
Published
react-device-mockup
Downloads
888
Readme
react-device-mockup
You can check out the
🌐 full-demo-here
Package for React Native is 🌐 here
Index
Introduction
react-device-mockup
provides frame mockups for Android and iOS devices.
You can use this library when you need a device demo for your app.
Every mockup is rendered as pure div
tags.
react-device-mockup
provides the following mockups:
- Android
- Phone: 19.5:9 aspect ratio,
AndroidMockup
- Tablet: 16:10 aspect ratio,
AndroidTabMockup
- Phone: 19.5:9 aspect ratio,
- iOS
- iPhone,
IPhoneMockup
- legacy iPhone: iPhone SE3
- notched iPhone: iPhone 14
- Dynamic island iPhone: iPhone 15 Pro
- iPad,
IPadMockup
- legacy iPad 4:3 aspect ratio (home button)
- modern iPad: 4.3:3 aspect ratio (no home button)
- iPhone,
Installation
No dependencies. Just install it
npm install react-device-mockup
or if you use yarn
yarn add react-device-mockup
How to use
import {
AndroidMockup,
AndroidTabMockup,
IPhoneMockup,
IPadMockup
}
from "react-device-mockup"
return (
<>
{/* Android Phone */}
<AndroidMockup screenWidth={200}>
{/* your demo */}
<YourComponent>
{...}
</YourComponent>
</AndroidMockup>
{/* Android Tablet */}
<AndroidTabMockup screenWidth={200}>
{/* your demo */}
<YourComponent>
{...}
</YourComponent>
</AndroidTabMockup>
{/* iPhone */}
<IPhoneMockup screenWidth={200}>
{/* your demo */}
<YourComponent>
{...}
</YourComponent>
</IPhoneMockup>
{/* iPad */}
<IPadMockup screenWidth={200}>
{/* your demo */}
<YourComponent>
{...}
</YourComponent>
</IPadMockup>
</>
)
Props
AndroidMockup & AndroidTabMockup
You can check demo
| prop | Required | Type | Default | Description |
| ------------------ | :------: | ---------------- | ----------- | ----------- |
| screenWidth | O | number
| | Width of mockup screen details |
| noRoundedScreen | X | boolean
| false
| No use rounded screen corners. |
| isLandscape | X | boolean
| false
| portrait or landscapefalse
means portrait |
| className | X | string
| | class name for mockup container |
| containerStlye | X | CSSProperties
| | Styles for mockup container |
| frameColor | X | Property.Color
| "#666666"
| Color of Frame |
| frameOnly | X | boolean
| false
| Only the frame is shown.Power button and volume buttons are hidden |
| statusbarColor | X | Property.Color
| "#CCCCCC"
| Color of status bar |
| hideStatusBar | X | boolean
| false
| Hide the status bardetails |
| navBar | X | "swipe"
"bhr"
"rhb"
| "swipe"
| Type of navigation bardetails |
| navBarColor | X | Property.Color
| "#CCCCCC"
| Color of navigation bar |
| transparentNavBar | X | boolean
| false
| Make the navigation bar transparent.details |
| hideNavBar | X | boolean
| false
| Hide the navigation bardetails |
| transparentCamArea | X | boolean
| false
| NOTE: AndroidMockup only.Make the area around the camera transparent.Only works when isLandscape=true
.details |
| children | X | ReactNode
| | Components to be rendered on the mockup screen |
IPhoneMockup & IPadMockup
You can check demo
| prop | Required | Type | Default | Description |
| ----------------- | :------: | ---------------- | ----------- | ----------- |
| screenWidth | O | number
| | Width of mockup screen details |
| screenType | X | "legacy"
"notch"
"island"
| "island"
| for IPhoneMokcup"legacy"
: Classic iphone such as iPhone SE3"notch"
: Notched iPhone such as iPhone 14"island"
: Dynamic island iPhone such as iPhone 15 Pro |
| screenType | X | "legacy"
"modern"
| "modern"
| for IPadMockup"legacy"
: Classic iPad such as iPad 9th"modern"
: Modern iPad such as iPad Pro 13-inch |
| isLandscape | X | boolean
| false
| portrait or landscapefalse
means portrait |
| className | X | string
| | class name for mockup container |
| containerStlye | X | CSSProperties
| | Styles for mockup container |
| frameColor | X | Property.Color
| "#666666"
| Color of Frame |
| frameOnly | X | boolean
| false
| Only the frame is shown.Power button and volume buttons are hidden |
| statusbarColor | X | Property.Color
| "#CCCCCC"
| Color of status bar |
| hideStatusBar | X | boolean
| false
| Hide the status bardetails |
| transparentNavBar | X | boolean
| false
| Make the navigation bar transparent.details |
| hideNavBar | X | boolean
| false
| Hide the navigation bardetails |
| children | X | ReactNode
| | Components to be rendered on the mockup screen |
screenWidth
Width of mockup screen.
The height is automatically calculated according to the ratio.
NOTE
It does not mean the full width of the mockup being rendered.
hideStatusBar
Hide the status bar.
false
: Status bar occupies its own space withstatusbarColor
. (default)true
: Status bar no longer occupies its own area, but becomes part of the screen area.
NOTE
WhenisLandscape=true
andscreenType="legacy"
iniPhoneMockup
,
the status bar is always hidden regardless ofhideStatusBar
.
Even on the REAL classic iPhone, the status bar is always hidden when in landscape mode.
navBar
Type of navigation bar.
"swipe"
: swipe gesture navigation bar. (modern style)"bhr"
: back-home-recent buttons. (classic style)"rhb"
: recent-home-back. (classic style)
This prop is only for
AndroidMockup
,AndroidTabMockup
transparentNavBar
Make the navigation bar transparent.
false
: Navigation bar occupies its own space withnavBarColor
. (default)true
: Navigation bar no longer occupies its own area, but becomes part of the screen area.- NOTE: Swipe bar or buttons are rendered according to the type specified by
navBar
props.
- NOTE: Swipe bar or buttons are rendered according to the type specified by
NOTE
WhenscreenType="legacy"
iniPhoneMockup
,transparentNavBar
is always ignored.
hideNavBar
Hide the navigation bar.
false
: Show the navigation bar. (default)true
: Hide the navigation bar.- Navigation bar no longer occupies its own area,
but becomes part of the screen area. - NOTE: Swipe bar or buttons are NOT rendered according to the type specified by
navBar
props.
- Navigation bar no longer occupies its own area,
NOTE
WhenscreenType="legacy"
iniPhoneMockup
,hideNavBar
is always ignored.
transparentCamArea
AndroidMockup only.
Make the area around the camera transparent.
It only works when isLandscape=true
.
It is ignored when isLandscape=false
CamArea (Camera area)
The part that was the status bar when in Portrait.
When in Landscape, in Android Native, this part is simply expressed as an empty (blank) area.This prop is only for
AndroidMockup
Demo
🌐 full-demo
Demo: Android
AndroidMockup
AndroidTabMockup
AndroidMockup
default mockups
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
AndroidTabMockup
default mockups
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
hideStatusBar & hideNavBar
hideStatusBar={true}
hideNavBar={true}
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
other props
| noRoundedScreen | frameColor="green"statusbarColor="red"navBarColor="blue" | | :--: | :--: | | | |
default with child
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
props.hideStatusBar
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
props.transparentNavBar
| isLandscape=false | isLandscape=true |
| :--: | :--: |
| navBar="bhr"
| navBar="bhr"
|
props.hideNavBar
| isLandscape=false | isLandscape=true | | :--: | :--: | | | |
props.transparentCamArea
AndroidMockup, landscape only | isLandscape=false | isLandscape=true | | :--: | :--: | | none | |
Demo: iOS
IPhoneMockup
IPadMockup
IPhoneMockup
All props not mentioned are default.
Props with the same name as props in AnroidMockup
work the same way.
| screenType | isLandscape=false | isLandscape=true |
| :--: | :--: | :--: |
| "island"
| | |
| "notch"
| | |
| "legacy"
| | |
IPadMockup
All props not mentioned are default.
Props with the same name as props in AnroidMockup
work the same way.
| screenType | isLandscape=false | isLandscape=true |
| :--: | :--: | :--: |
| "modern"
| | |
| "legacy"
| | |
License
MIT license