Layout3D
The Layout3D component is a structural element designed to act as a container for 3D transformations. It sets up a 3D scene by defining a distance property, which controls the perspective. This perspective determines how far the user is from the z-plane of the 3D scene, affecting how 3D transformations appear.
The default use case for the Layout component is as a container for 3D scenes. It pairs seamlessly with the Transform component to apply 3D transformations.
import Layout3D from '@components/Layout/Layout3D/Layout3D';import Transform from '@components/Layout/Transform/Transform';
const App = () => { return ( <Layout3D distance='2500px'> <Transform matrix={{ scale={x: 2, z: 2}, translate={z: 150} }}>Element scaled by 2 by the x and y axes and translated towards the user by 150px. </Transform> </Layout3D> );};
export default App;| Prop Name | Type | Default | Description |
|---|---|---|---|
style | JSX.CSSProperties | {} | Inline styles to apply directly to the component’s root element. |
class | string | "" | Additional CSS classes to apply to the component |
ref | HTMLDivElement | undefined | Retrieves the component’s DOM element and assigns it to a variable. |
distance | string | 0 | Defines the perspective distance (z-plane to user). Use valid CSS unit values (e.g., px, em, %). |
onAction | Record<string, (scope?: string, ...args: any[]) => void> | undefined | Allows you to add custom navigation action handlers to the component. See the Navigation component documentation for details. |
anchor | string | HTMLElement | undefined | Links navigation to another element. When the anchor element is focused, this component’s actions will execute. Can be a CSS selector or HTMLElement. |
Setting Up a 3D Scene
Section titled “Setting Up a 3D Scene”The Layout3D component is the foundational container for 3D scenes. By specifying the distance prop, you control the perspective effect. Combine it with the Transform component to achieve dynamic 3D transformations.
import Layout3D from '@components/Layout/Layout3D/Layout3D';import Transform from '@components/Layout/Transform/Transform';
const App = () => { return ( <Layout3D distance="1200px"> <Transform matrix={{ rotate: { y: 45 }, translate: { z: -200 } }}> Rotated by 45° on the y-axis and moved 200px away from the user. </Transform> </Layout3D> );};
export default App;Accessing the HTML element
Section titled “Accessing the HTML element”To access the HTML DOM element of the Layout3D component.
- Declare a variable to hold the ref but don’t initialize it with a value
- The declared value should have a type of
HTMLDivElement. - Set the declared variable as the value of the
refprop of theLayout3Dcomponent
Example
Section titled “Example”import Layout3D from '@components/Layout/Layout3D/Layout3D';import Transform from '@components/Layout/Transform/Transform';
const App = () => { let layout3DRef!: HTMLDivElement
return ( <Layout3D ref={layout3DRef} distance='2500px'> <Transform matrix={{ scale={x: 2, z: 2}, translate={z: 150} }}>Element scaled by 2 by the x and y axes and translated towards the user by 150px. </Transform> </Layout3D> );};
export default App;Now you can access the HTML element of Layout3D with layout3DRef and make modifications to it if needed.
© 2026 Coherent Labs. All rights reserved.