Device

@sushindustries/ui

A phone, a tablet or a laptop in CSS 3D, chosen by the stylesheet rather than by JavaScript, with a real screen in it.

9 min read
View as MarkdownEdit on GitHub

Install commands are on Home, attached from the registry - they are not written here, because a second copy is a copy that goes stale. This tab starts after the install worked.

Use it

import { Device } from "@sushindustries/ui";

export function Example() {
	return (
		<Device title="a machine">
			<p className="p-4 fg-dim m-0 text-sm">The desktop goes here.</p>
		</Device>
	);
}
tsx

What you should see

A phone, a tablet or a laptop drawn in 3D, tilted as if you were looking at it rather than photographing it flat on. Which one you get depends on the width of the window this page is open in - resize the browser and it changes at 720px and 1080px, with no flash and no flicker while it does.

If nothing happens

All three machines are always in the DOM; the stylesheet just hides the ones that do not apply at the current width. If nothing ever changes as you resize, the atoms stylesheet is not loaded - this component draws nothing on its own, devices.css is what decides which machine shows. Content passed as children is a real scroll container, so if it looks cut off, give it content tall enough to actually scroll rather than assuming the frame is broken.

UsesuseDeviceKinduseDeviceKindWhich machine the stylesheet is currently drawing, as a value. Null until mounted, on purpose - a default would be a claim the server cannot support.@sushindustries/ui · layout
Used byShowcaseShowcaseA component in a real iframe at every width it has to survive, side by side, with its source and install commands.@sushindustries/ui · docs