Skip to main content

Command Palette

Search for a command to run...

Display Your Website or Application in a Realistic Device Layout Using the device-layouts NPM Package

Learn how to showcase your website or application in a professional manner by using the device-layouts package, and customize the device layout styles

Updated
β€’2 min read
Display Your Website or Application in a Realistic Device Layout Using the device-layouts NPM Package
J

a simple man

Hello Devs 😊

Device-Layouts NPM

Introduction:

The device-layouts npm package is a useful tool for web developers who want to showcase their website or application in a realistic device layout. It provides MacBook and iPhone device frames in SVG format that can be easily integrated into a web page. In addition to its default features, the package also allows you to customize the CSS styles of the device layouts. In this article, we will explore how to customize the CSS styles of the device-layouts package.

Installation:

The first step in using the device-layouts package is to install it in your project. You can do this by running the following command in your terminal:

npm install device-layouts

Once the installation is complete, you can start using the package in your project.

Usage:

To use the device-layouts package, you need to import it into your project and pass an element to be displayed in the device layout. Here's an example:

import React from "react";
import Layouts from "device-layouts";

const App = () => {
  const element = (
    <div>
      <iframe
        src="https://www.example.com"
        width="100%"
        height="800"
      ></iframe>
    </div>
  );
  const { Laptop, Iphone } = Layouts({ element });
  return (
    <>
      <Laptop />
      <Iphone />
    </>
  );
};

export default App;

CSS Styles: The device-layouts package also allows you to customize the CSS styles of the device layouts. You can add new styles or override the pre-defined ones. The pre-defined CSS styles are located in ./src/assets/css/style.css and include the following classes:

  • laptop_layout

  • iphone_layout

  • laptop_layout_child

  • iphone_layout_child

Laptop Layout:

iPhone Layout:

Conclusion:

In this article, we have explored how to use the device-layouts npm package to display your website or application in a realistic device layout.

The device-layouts package is a useful tool for web developers who want to showcase their projects in a realistic and visually appealing way.

Happy Coding β˜•

S

Great post! Displaying a website or application in a realistic device layout can really enhance the user experience and make it more engaging for visitors. The device-layouts NPM package seems like a really useful tool for achieving this, and I appreciate the detailed explanation of how to use it.

One thing I especially liked about this post was the emphasis on responsive design. It's so important to ensure that websites and applications look great on all devices, and using device layouts can be a helpful way to visualize how content will look on different screen sizes. I also appreciated the examples provided, which gave me a better sense of how the package works in practice.

Overall, this was a helpful and informative post. Thanks for sharing your knowledge!

1
J

hey! I am glad to hear that! Thanks friendπŸ™‚

1
D

Nice

1
J

Thanks, man πŸ™‚