Every part that renders an element accepts render. Use it when the default element is not the one you want: a button from your design system, a link instead of a button. You don't need it to style a part; for that, see Getting started.
The element form replaces the default element and merges the library's props into it. The function form hands you the props and the state, and you render the element yourself.
// Element form: a design-system button. It must accept `ref` and spread its props.
<Toggle render={<MyButton variant="ghost" />}>Bold</Toggle>
// Function form: full control.
<Toggle render={(props, state) => <button {...props}>{state.pressed ? "On" : "Off"}</button>} />On every component page, each part's props table is followed by two fixed lines: State, the object the function props and render receive, and Owned, the props the part sets itself, which a render element cannot override. Everything not listed passes through to the element.
An owned key that is not one of the part's own props is also left out of its props type, in every mode, so passing it is a type error: the role, the ARIA state the part computes, type, a roving tabIndex, the invoker attributes of a Trigger, and every event handler the part passes to its element (in any mode). TypeScript checks a hyphenated attribute such as aria-selected only in an object typed as the props, not as a JSX attribute; at runtime the part's value wins either way. Three kinds of owned key stay in the type: the ARIA id lists the part merges with yours (marked "token-merged"), a key the part only removes in one case and otherwise passes through, and a key owned only inside another component (a control's id inside a Field.Root). For the raw event of a handler the part installs, put your handler on the render element (it runs first) or use ref with addEventListener.
className values are concatenated; style objects are merged (the element wins). Event handlers the part installs run after the element's own, with one exception: the click of an unavailable part runs none.role, ARIA state, ids, data-* state) always win. ARIA id lists (aria-describedby, aria-labelledby, aria-controls) are merged instead.type="button" is added when the rendered element is a <button> or a component (which may render one), and left out for another HTML element such as <a>.ref and the element's. A router link that merges refs the React 18 way works too (react-router's Link builds a new ref callback on every render and calls the old one with null): the part treats that as the same element staying attached, not as an unmount and a new mount.disabled prop, disabled is owned: the element cannot re-enable a disabled part, and a disabled on the element disables the part, as if you had set it on the part.A part is unavailable while it is disabled (its own disabled, its Root's or Field's, or its render element's), and while a part with whilePending="ignore" ignores clicks because its action is pending. It then renders native disabled or aria-disabled="true", and a click on it does nothing for anyone, as on a natively disabled button:
onClick runs: not the render element's, not one passed to the part, not the part's own action, and not the handler of another part composed with it.onPointerDown, onKeyDown, focus and hover handlers run as usual: a focusable disabled control must still take focus, arrow keys and a tooltip.// `open` is not called while the item is disabled, for a pointer, Enter and Space alike.
<Menu.Item disabled={!canExport} render={<button onClick={open} />}>Export…</Menu.Item>
// The dialog does not open and `track` does not run while the Button is disabled.
<Dialog.Trigger render={<Button disabled focusableWhenDisabled render={<a onClick={track} />} />}>
Edit
</Dialog.Trigger>When one part renders another (<Dialog.Trigger render={<Button />}>), the element is unavailable when either part is: put disabled on whichever you like. To see the click of a disabled part anyway (analytics, a hint about why it is disabled), use onClickCapture on the render element, or ref with addEventListener. Not affected: the Trigger of a disabled Tooltip or HoverCard and a disabled Menu.ContextTrigger, whose disabled turns the overlay off and leaves the element yours.