Skip to main content

IsometricCube

IsometricCube renders a cube using a required size and depth, with individual faces added through IsometricCube.Side.

Import

import { IsometricCube } from "isometric-react/isometric-cube";

Props (IsometricCube)

PropTypeRequiredDescription
size{ width: number; height: number }YesBase cube dimensions.
depthnumberYesCube depth.
childrenReact.ReactNodeNoUsually one or more IsometricCube.Side elements.
asReact.ElementTypeNoPolymorphic element type.
positionPositionNoOffsets and elevation values.
borderBorderNoBorder styling for rendered faces.
shadowShadowNoShadow distance and spacing settings.
shadowAnimationShadowAnimationNoAnimated shadow configuration.
rotationRotationNoRotation animation configuration.

Props (IsometricCube.Side)

PropTypeRequiredDescription
side"top" | "front-left" | "front-right" | "bottom" | "back-left" | "back-right"YesWhich cube face to render.
childrenReact.ReactNodeYesWhat to render inside the face.

Basic usage

import { IsometricCube } from "isometric-react/isometric-cube";

export function BasicCube() {
return (
<IsometricCube size={{ width: 5, height: 5 }} depth={2}>
<IsometricCube.Side side="top" />
<IsometricCube.Side side="front-left" />
<IsometricCube.Side side="front-right" />
<IsometricCube.Side side="bottom" />
<IsometricCube.Side side="back-left" />
<IsometricCube.Side side="back-right" />
</IsometricCube>
);
}

Rendered example

TOP
FRONT LEFT
FRONT RIGHT

With optional props

import { IsometricCube } from "isometric-react/isometric-cube";

export function StyledCube() {
return (
<IsometricCube
size={{ width: 5, height: 5 }}
depth={2}
as="section"
position={{ top: 2, left: 1, elevation: 1 }}
border={{ size: 1, style: "solid", color: "#2f2f2f" }}
shadow={{ distance: 2, spacingX: 1, spacingY: 1 }}
>
<IsometricCube.Side side="top" />
<IsometricCube.Side side="front-left" />
<IsometricCube.Side side="front-right" />
</IsometricCube>
);
}

Supported shared props

IsometricCube does not support the edge prop.