useRender
Renders a Base UI element with support for custom render functions and conditional rendering.Import
Hook Signature
Parameters
UseRenderRenderProp<State> | undefined
The React element or a function that returns one to override the default element.
React.Ref<RenderedElementType> | React.Ref<RenderedElementType>[] | undefined
The ref to apply to the rendered element. Can be a single ref or an array of refs.
State | undefined
The state of the component, passed as the second argument to the
render callback. State properties are automatically converted to data-* attributes.StateAttributesMapping<State> | undefined
Custom mapping for converting state properties to data-* attributes.Example:
Record<string, unknown> | undefined
Props to be spread on the rendered element. They are merged with the internal props of the component, so that event handlers are merged,
className strings and style properties are joined, while other external props overwrite the internal ones.Enabled | undefined
default:"true"
If
false, the hook will skip most of its internal logic and return null. This is useful for rendering a component conditionally.keyof React.JSX.IntrinsicElements | undefined
default:"'div'"
The default tag name to use for the rendered element when
render is not provided.Return Value
ReturnsReact.ReactElement when enabled, or null when enabled is false.