Go back

div-phone

A phone frame React component built with Tailwind CSS classes.

I've often used CSS to render physical devices on the canvas, wrapping {children} like interactive apps. The div-phone package is a lightweight solution that applies these same concepts to the iPhone.

Just import and wrap {children}, and you're done.

Install

npm install div-phone

Usage

import { Phone } from 'div-phone';
export const Example = () => (
<Phone shadow>
<div className="h-full w-full bg-neutral-900 text-white">{/* Your app goes here. */}</div>
</Phone>
);

Props

Tailwind setup

Because the component uses Tailwind classes, make sure your Tailwind config includes the package in content so classes are not purged:

export default {
content: ['./src/**/*.{ts,tsx,js,jsx}', './node_modules/div-phone/**/*.{ts,tsx,js,jsx}'],
};

This component uses modern Tailwind utilities like size-* and arbitrary values. If you run into missing styles, verify you are on Tailwind CSS v4 and using @tailwindcss/postcss v4 with PostCSS v8.

For Tailwind v4, your PostCSS config should include the Tailwind plugin:

export default {
plugins: {
'@tailwindcss/postcss': {},
},
};

Using div-phone for something cool? Tag me on 𝕏 with what you've built!