Migrating from 0.* to 1.*
How to migrate a from react-three/uikit 0.* to react-three/uikit 1.*
Why this release
- More alignment with html/css
pmndrs/uikitis now the stable core for vanilla three.js.react-three/uikitis a thin layer on top.- The core can be used across three.js-based frameworks (IWSDK, vanilla three.js, react-three/fiber).
- Component and icon kits are available across vanilla and other frameworks.
- Simpler code for better maintainability.
What’s new (Added)
zIndexto control render order (like html/css).display: contents(Yoga 3.2).white-spaceto control whitespace in text, inputs, …- Global classes via
StyleSheet. *property to set default properties for all descendants.- Input
placeholdersupport. importantto raise style precedence (works with*).- support for modifying the position, scale, rotation directly on the outer most uikit component's removing the necessity to wrap every UI in a group to control its transformation in 3D space
What changed
- Properties that inherit in html/css now inherit in uikit as well.
pixelSizecan be set anywhere and inherits to descendants.textAlign: block→textAlign: justify.Imagecan no longer have children. Wrap the image in a relatively positioned container; put children inside withposition: absoluteand a higherzIndex.refis now a proper uikit three.js component with typings and full internal access.setStyle→setProperties(more robust and performant; can update all properties).border/borderX/… →borderWidth/borderXWidth/… (matches html/css).lineHeightwithout a unit is a multiplier; withpxit’s absolute (matches html/css).scrollbarBackgroundColor→scrollbarColor.
Deprecated (React)
Root: useContaineror remove if unnecessary.DefaultProperties: use<Container display="contents" {...{ '*': defaultProps }}>or write defaults using'*'on any component.FontFamilyProvider: providefontFamilieson aContainerwithdisplay="contents"or on existing components.Icon→Svg; propertytext→content.
Removed
backgroundOpacityandborderOpacity. Opacity is part of the color now (background/border), like html/css. UsewithOpacityor theuseWithOpacityReact hook.useRootSize. Access the root via any element ref:anyComponent.root.value.component.size.value.isInteractionPanel. All uikit elements are interaction panels now.apfel-kit(low usage).
Quick migration checklist
- Replace
RootwithContainer(or remove if not necassary). - Replace
DefaultPropertieswith aContainer display="contents"and'*'defaults. - Move
FontFamilyProvidertofontFamilieson aContaineror any other component. - Replace
IconwithSvgand rename thetextproperty →content. - Rename
setStyle→setProperties. - Rename
border*→border*Widthvariants. - Update
textAlign: block→justify. - Remove
backgroundOpacity/borderOpacity; use color with alpha orwithOpacity/useWithOpacity. - Remove
isInteractionPanelusage - Remove
useRootSize; use refs to access root size. - Ensure
Imagehas no children; wrap with a relative container and place children absolutely with higherzIndex.