uikit Full documentation content. Perfect for games, XR (VR/AR), and any web-based Spatial Computing App. ```bash npm install three @react-three/fiber @react-three/uikit ``` ### What does it look like? ) }`}} /> ## How to get started If you are using `@react-three/fiber`, get started with **[building your first layout](./first-layout.mdx)**, take a look at our **[examples](./examples.md)** to see uikit in action. If you want to use vanilla three.js, visit [this tutorial](./vanilla.md). Alternatively, learn more about: - [All components and their properties](./components-and-properties.md) - [Globals (defaults, classes, color scheme)](./globals.mdx) - [Interactivity](../tutorials/interactivity.mdx) - [Custom materials](../tutorials/custom-materials.md) - [Custom fonts](../tutorials/custom-fonts.md) - [Responsive user interfaces](../tutorials/responsive.md) - [Scrolling](../tutorials/scroll.md) - [Sizing](../tutorials/sizing.md) - [Common pitfalls](../advanced/pitfalls.md) - [Optimize performance](../advanced/performance.md) - [Theming components](../advanced/theming.mdx) ## Pre-styled component kits We provide multiple kits containing **themable pre-styled components**. |

default-kit

_based on [Shadcn](https://github.com/shadcn-ui/ui)_ |

horizon-kit

_based on [RLDS](https://www.figma.com/de-de/community/file/1509641173090552632/meta-horizon-os-ui-set)_ | | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | ![Overview over all default components](./default-overview.jpg) | ![Overview over all horizon components](./horizon-overview.png) | | [View All Components](../default-kit/accordion.mdx) | [View All Components](../horizon-kit/avatar.mdx) | | install via `@react-three/uikit-default` or `@pmndrs/uikit-default` | install via `@react-three/uikit-horizon` or `@pmndrs/uikit-horizon` | ## Migration guides - from [Uikit 0.\*](../migration/from-version-0.md) ## Sponsors This project is supported by a few companies and individuals building cutting edge 3D Web & XR experiences. Check them out! ![Sponsors Overview](https://bbohlender.github.io/sponsors/screenshot.png) ]]>
[!TIP] > The `@react-three/drei` dependency is not necessary but allows us to add `OrbitControls`. Next, we create the `index.jsx` file and import the necessary dependencies. ```jsx showLineNumbers import { Canvas } from '@react-three/fiber' import { OrbitControls } from '@react-three/drei' import { Container } from '@react-three/uikit' ``` Now, we can start defining the actual layout. In this example, the `Container` is of size 8 by 4 (three.js units). The `Container` has a horizontal (row) flex-direction, with 2 `Container` children, filling its width equally with a margin around them. More in-depth information on the Flexbox properties can be found [here](https://yogalayout.dev/docs/). ```jsx {5-8} showLineNumbers=5 export default function App() { return ( ) } ``` The final result will look like this: ) }`}} /> ]]>
  • [![Screenshot from Card example](./example-card.png)](https://pmndrs.github.io/uikit/examples/card/)
  • [![Screenshot from Dashboard example](./example-dashboard.png)](https://pmndrs.github.io/uikit/examples/dashboard/)
  • [![Screenshot from Market example](./example-market.png)](https://pmndrs.github.io/uikit/examples/market/)
  • [![Screenshot from Lucide example](./example-lucide.png)](https://pmndrs.github.io/uikit/examples/lucide/)
  • [![Screenshot from Auth example](./example-auth.png)](https://pmndrs.github.io/uikit/examples/auth/)
  • ]]>
    View all base properties | Property | Type | | -------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | visibility | "visible" , "hidden" | | margin | number, Percentage, "auto" | | marginX | number, Percentage, "auto" | | marginY | number, Percentage, "auto" | | marginTop | number, Percentage, "auto" | | marginLeft | number, Percentage, "auto" | | marginRight | number, Percentage, "auto" | | marginBottom | number, Percentage, "auto" | | transformTranslateX | number | | transformTranslateY | number | | transformTranslateZ | number | | transformScaleX | number | | transformScaleY | number | | transformScaleZ | number | | transformOriginX | "left", "center", "middle", "right" | | transformOriginY | "top", "center", "middle", "bottom" | | transformRotateX | number | | transformRotateY | number | | transformRotateZ | number | | positionType | "absolute", "relative", "count" | | inset | number, Percentage | | positionTop | number, Percentage | | positionLeft | number, Percentage | | positionRight | number, Percentage | | positionBottom | number, Percentage | | alignContent | "space-evenly", "space-around", "space-between", "baseline", "stretch", "flex-end", "center", "flex-start", "auto" | | alignItems | "space-evenly", "space-around", "space-between", "baseline", "stretch", "flex-end", "center", "flex-start", "auto" | | alignSelf | "space-evenly", "space-around", "space-between", "baseline", "stretch", "flex-end", "center", "flex-start", "auto" | | flexDirection | "row-reverse", "row", "column-reverse", "column" | | flexWrap | "wrap-reverse", "wrap", "no-wrap" | | justifyContent | "space-around", "space-between", "flex-end", "center", "flex-start", "space-evenly" | | flexBasis | number, Percentage | | flexGrow | number | | flexShrink | number | | width | number, Percentage, "auto" | | height | number, Percentage, "auto" | | minWidth | number, Percentage | | minHeight | number, Percentage | | maxWidth | number, Percentage | | maxHeight | number, Percentage | | aspectRatio | number | | borderWidth | number | | borderXWidth | number | | borderYWidth | number | | borderTopWidth | number | | borderLeftWidth | number | | borderRightWidth | number | | borderBottomWidth | number | | overflow | "visible", "scroll", "hidden" | | padding | number, Percentage | | paddingX | number, Percentage | | paddingY | number, Percentage | | paddingTop | number, Percentage | | paddingLeft | number, Percentage | | paddingRight | number, Percentage | | paddingBottom | number, Percentage | | gap | number | | gapRow | number | | gapColumn | number | | receiveShadow | boolean | | castShadow | boolean | | depthTest | boolean | | depthWrite | boolean | | renderOrder | number | | backgroundColor | ColorRepresentation | | panelMaterialClass | Material class | | borderColor | ColorRepresentation | | borderRadius | number | | borderLeftRadius | number | | borderRightRadius | number | | borderTopRadius | number | | borderBottomRadius | number | | borderTopLeftRadius | number | | borderTopRightRadius | number | | borderBottomRightRadius | number | | borderBottomLeftRadius | number | | borderBend | number | | scrollbarPanelMaterialClass | Material class | | scrollbarColor | ColorRepresentation | | scrollbarWidth | number | | scrollbarBorderRadius | number | | scrollbarBorderLeftRadius | number | | scrollbarBorderRightRadius | number | | scrollbarBorderTopRadius | number | | scrollbarBorderBottomRadius | number | | scrollbarBorderTopLeftRadius | number | | scrollbarBorderTopRightRadius | number | | scrollbarBorderBottomRightRadius | number | | scrollbarBorderBottomLeftRadius | number | | scrollbarBorderColor | ColorRepresentation | | scrollbarBorderBend | number | | scrollbarBorderRightWidth | number | | scrollbarBorderTopWidth | number | | scrollbarBorderLeftWidth | number | | scrollbarBorderBottomWidth | number | | scrollbarZIndex | number | | zIndex | number | | zIndexOffset | number | | color | ColorRepresentation | | fill | ColorRepresentation | | opacity | number | | textAlign | "left", "center", "right", "justify" | | verticalAlign | "top", "center", "bottom" | | letterSpacing | number | | lineHeight | number | | fontSize | number | | wordBreak | "keep-all", "break-all", "break-word" | | fontFamily | string | | fontWeight | number, "bold", "thin", "extra-light", "light", "normal", "medium", "semi-bold", "extra-bold", "black", "extra-black" | | whiteSpace | "normal", "collapse", "pre", "pre-line" | | pixelSize | number | | sizeX | number | | sizeY | number | | caretColor | ColorRepresentation | | caretWidth | number | | caretBorderColor | ColorRepresentation | | caretBorderBend | number | | caretBorderTopLeftRadius | number | | caretBorderTopRightRadius | number | | caretBorderBottomLeftRadius | number | | caretBorderBottomRightRadius | number | | caretBorderRightWidth | number | | caretBorderTopWidth | number | | caretBorderLeftWidth | number | | caretBorderBottomWidth | number | | selectionColor | ColorRepresentation | | selectionWidth | number | | selectionBorderColor | ColorRepresentation | | selectionBorderBend | number | | selectionBorderTopLeftRadius | number | | selectionBorderTopRightRadius | number | | selectionBorderBottomLeftRadius | number | | selectionBorderBottomRightRadius | number | | selectionBorderRightWidth | number | | selectionBorderTopWidth | number | | selectionBorderLeftWidth | number | | selectionBorderBottomWidth | number | | pointerEvents | "none", "auto", "listener" | | pointerEventsType | `"all", \{ allow: string, string[] \}, \{ deny: string | string[] \}, (fn)` | | pointerEventsOrder | number | | anchorX | "left", "center", "middle", "right" | | anchorY | "top", "center", "middle", "bottom" | | id | string | | cursor | string | | fontFamilies | `Record>>` | **`lineHeight` Note:** Just like in html/css, numeric line heights represent multipliers (e.g. `1.3`) while line heights with a `px` suffix represent absolute pixel values e.g. `20px`. **`zIndexOffset` Explanation:** Generally using `zIndex` is recommended as it behaves just like `zIndex` in the browser. `zIndexOffset` allows to manipulate the internal default order deduced from the UI hierachy, giving the developer the option to shift the order of specific elements backwards or forwards making them appear behind or infront of other elements. Note that sibling elements are treated as having the same UI hiearchy and are therefore not explicitly ordered. Using `zIndexOffset={1}` can be faster then using `zIndex` as it allows to order sibling elements of the same type e.g. with two overlapping panels beeing siblings in the UI hiearchy. ## Container The `Container` componet is a basic UI component that allows wrapping children and rendering a Panel into the background. It corresponds to the HTML `div` element. ```jsx showLineNumbers ... ``` The Container has exactly all the base properties and nothing more. ## Fullscreen The `Fullscreen` component wraps the `Container` component and binds its content directly to the viewport based on the provided `distanceToCamera`. The `Fullscreen` component automatically sets the correct pixelSize, sizeX, and sizeY properties on the `Container` component so that pixel sizes align with the pixels of the screen. In addition, the `Fullscreen` component has all the properties of the `Container` component. ```jsx showLineNumbers ```
    View all properties specific to the `Fullscreen` component | Property | Type | | ---------------- | ------- | | attachCamera | boolean | | distanceToCamera | number |
    ## Image The `Image` component has the same properties and functionalities as a `Container` component but allows you to render an image inside it. The `Image` component corresponds to the HTML `img` element. The `Image` component has the `src` property, which can take an URL or a three.js texture. The `Image` component automatically sets the `aspectRatio` property based on the `src` property. This behavior can be turned off through `keepAspectRatio={false}`. The `objectFit` property can also be used to `cover` or `fill` the image in case the aspect ratio cannot be preserved by the layout engine or was overwritten by the user. ```jsx showLineNumbers ```
    View all properties specific to the `Image` component | Property | Type | | --------------- | --------------- | | src | string, Texture | | objectFit | "fill", "cover" | | keepAspectRatio | boolean |
    ## SuspendingImage The default image doesn't use react's suspense but rather loads the image silently. To explicitly control how the image behaves when loaded, use the `SuspendingImage` component. The component can be used to display a fallback component while the image is loading. It has the same properties as the `Image` component. ```jsx showLineNumbers } > ``` ## Portal The `Portal` component uses the `Image` component under the hood to render its children into a render target, which is displayed on the surface of the `Portal` component. In contrast to the `Image` component, the `Portal` component doesn't have a default `aspectRatio` or an `src` property. The size of the portal is completly controlled through the flexbox properties, the resolution of the portal is equal to the size multiplied by the `dpr` property, which defaults to the system `dpr`. ```jsx showLineNumbers ``` ## Video The `Video` component has the same properties and functionalities as a `Image` component but allows you to render an video inside it. The `Video` component corresponds to the HTML `video` element. The `Video` component has the `src`, `volume`, `preservesPitch`, `playbackRate`, `muted`, `loop`, and `autoplay` property to setip the video and can even be used to play media streams. To control playing the video the `Video` provide the html video element through a provide, that can be consumed by its children through `useVideoElement` to create video controls. Additionally, the html video element can be received from the parent of the `Video` using `ref.current.element`. ```jsx showLineNumbers