"Transition by default" is about state the library owns. Some state belongs to the browser, which changes it before React hears about it. FUNSTACK UI prefers that state whenever the platform offers it, because it is the only way a component can work without JavaScript.
<details> is open, whether a popover is in the top layer (the layer the browser draws above the whole page), whether a dialog is shown. The library reads it; it does not keep a copy in React state.popovertarget (the Popover API) or through commandfor and command (Invoker Commands). A <button> or an <input type="button"> / <input type="reset"> can be one; a disabled button and a submit button inside a form are not. See Triggers of a popup.details.reason: "platform", and re-applies the committed state afterwards.openChangeAction) before it is committed. A fact is a change that had already happened when the library heard of it, and that it could not hold: it is reported to an `on*` handler (onOpenChange). Both terms are defined on Action props; see Requests and facts for what they mean for a popup.on* handler), the browser owns the state and the library adds no behaviour on the native path. In library mode (any of those props), the state is library-owned. See Two modes.| Library-owned | Browser-owned | |
|---|---|---|
| Who changes it | the library, inside its transition | the browser (hover, light dismiss, Escape, find-in-page, a summary click, an invoker) |
| Optimistic state | React state (optimistic, useOptimistic) | the DOM itself |
| Callback | an action prop for a request, awaited; an on* handler for a fact (typed text) | an on* handler for a fact (onOpenChange), not awaited; or none |
| Styling | data-* attributes | pseudo-classes: :popover-open, :open |
| Animation | transition prop (<ViewTransition>) | CSS: @starting-style, transition-behavior: allow-discrete |
The library never mirrors browser-owned state into React state. It reads the DOM when it needs to, and it does not duplicate a pseudo-class with a data attribute. State that nobody persists or awaits is left to the browser entirely, with no prop and no action. Whether a hint popup (such as a tooltip) is showing is one example. One read is mirrored: whether a popup is shown, where no native element exposes it to assistive technology: on a Trigger that is no invoker, and on the Combobox input (see Triggers of a popup). Each component page says what it leaves to the browser in its Browser-owned state section.
Example: Tooltip
A tooltip's visibility is not application state. The popup is a popover in the top layer, so Tooltip has no open prop, no action and no data-open: :popover-open already says it. Style and animate it in CSS:
.tip { opacity: 0; transition: opacity 120ms, display 120ms allow-discrete, overlay 120ms allow-discrete; }
.tip:popover-open {
opacity: 1;
@starting-style { opacity: 0; }
}
/* The trigger of an open tooltip: the popup is its next sibling. */
.trigger:has(+ .tip:popover-open) { outline: 1px solid; }Some components built on a native element that does the whole interaction offer both (their pages have a Two modes section). Without any controlled value, default value, change action or on* handler it runs in JS-free mode: the browser owns the state and nothing runs when it changes. Add any of them and the component switches to library mode: the native interaction is intercepted, the state is React state changed in a transition, and triggers get optimistic data attributes and data-pending. The parts and the markup are the same in both. The mode is decided on the first render; switching between them later is not supported (development warning).
The browser can still change the state in library mode (find-in-page, a text fragment, a click before hydration). The component turns that into a regular dispatch with details.reason === "platform", and once the action settles it re-applies the committed state to the DOM, so a controlled parent that refuses the change gets its state back.
Example: Accordion
An Accordion without value, defaultValue and valueChangeAction leaves every <details open> to the browser, and exclusive renders the native name group. With any of them, the summary click is intercepted and open state changes in a transition.
// JS-free: the browser owns open state.
<Accordion.Root exclusive>...</Accordion.Root>
// Library mode: transitions, actions, optimistic state.
<Accordion.Root exclusive defaultValue={null} valueChangeAction={save}>...</Accordion.Root>For something that opens and closes in library mode, a change is either a request or a fact, and each has its own prop. Opening, and a close the user asks one of the component's parts for, are requests: the click, submit or command is cancelled and dispatched in a transition, openChangeAction is awaited, a controlled parent can veto it, and it can animate with a view transition. A dismissal is a fact: the element closes natively and at once, and onOpenChange(false, details) is called synchronously from the browser's own event. Nothing is pending, no view transition runs (a CSS exit animates it), and the committed state is false in the same event. A close the library performs itself but cannot hold, because the user has already moved on (focus leaving the popup), is a fact too.
The line sits where the platform lets the library cancel a step freely: a part's click (which cancels its command), a command event, a form's submit. Escape and the back gesture reach the element as an HTML close request (the platform's term, not a request in the sense above), whose cancel event the browser honours only once per user activation, and a user who pressed Escape expects the element to go away now. So the library never holds a dismissal.
A popup the browser opened before hydration is still a request (openChangeAction(true, { reason: "platform" })): the library can roll it back by hiding the empty popup, and its load-on-open code runs. So onOpenChange is only ever called with false.
Controlled mode needs both props. Pass the same setter to both: openChangeAction adopts a request (in a transition), onOpenChange adopts a fact (an urgent update). Set state directly in onOpenChange, never in startTransition and never after an await: a parent that still says open={true} once the browser's event has been handled gets the element shown again at once, and a late false then closes it a second time. A controlled Root without onOpenChange warns in development.
A parent that keeps open={true} after a dismissal on purpose gets the same re-open. This is not a veto: the user sees the element close and come back, possibly for a frame. A popup that must not be dismissed is set up on the platform side instead, where the component offers it. The re-open never moves focus: a Menu, a Combobox, a Popover (its default <dialog> as well as a <div>) or a non-modal Dialog shown again this way leaves focus where the dismissal put it (the Trigger after Escape, the field the user clicked, the next field after Tab). So a parent that never adopts false cannot trap the keyboard in the popup, and the re-open does not take focus away from the field the user just clicked. A modal Dialog (the default) is the exception: it must hold focus, so its re-open moves focus inside as on any open.
Uncontrolled, pass what you need. openChangeAction for work an open or a part's close must wait for (loading data on open); onOpenChange to observe a dismissal (logging it, remembering it). To hear every close, pass one function to both props and check its first argument: the action is called with true for an open too.
Example: Dialog
A library-mode Dialog opens through its Trigger and closes through its Close parts and Dialog.Form after openChangeAction resolves. Escape or a click outside closes it at once and calls onOpenChange(false, details) with reason: "dismiss". Controlled, with both props:
const [open, setOpen] = useState(false);
<Dialog.Root open={open} openChangeAction={setOpen} onOpenChange={setOpen}>A Dialog without lightDismiss ignores a click outside; Escape still closes a modal dialog.
A layer here is anything an Escape can close: a popup, a dialog, a toast, or the unsaved text of an input that reverts on Escape. Layers nest (a tooltip inside a dialog, a listbox inside a drawer), and one Escape closes only one of them. The browser does this for the layers it owns (a modal dialog, an auto popover) through its close watchers. Where the library handles Escape in JavaScript, it follows the same order:
To keep a layer open on Escape, call preventDefault() on the keydown. stopPropagation() keeps none open: the browser skips the close request only for a cancelled keydown, and the library reads the same signal. An Escape pressed during an IME composition only ends the composition.
Example: Tooltip
A Tooltip shown inside an open Dialog: the first Escape hides the tooltip and the dialog stays open; the second Escape closes the dialog.
A component whose popup is a popover has a Trigger: the part that opens and closes it. A Trigger rendered as a <button> names the popup with popovertarget, which makes it the popup's invoker. That relationship gives it three things from the browser:
aria-expanded; ARIA in HTML forbids the attribute on an element with popovertarget.A component may give up one of these on purpose; its page says so.
Only a <button> can be the Trigger's invoker. A Trigger rendered as a link or another element works through the library's click handler instead, and has none of the above: it renders aria-expanded itself, from whether the popup is shown; and a press on it while the popup is open counts as a click outside, so light dismiss closes the popup before the click arrives. That close is a fact, reported to onOpenChange (with reason: "activate" and the click), not a request: it is not awaited, a controlled parent cannot veto it, and there is no view transition. A development warning says so. A disabled Trigger that stays focusable (it renders aria-disabled) is no invoker either, so that nothing native can open the popup.
Two kinds of open state on a Trigger. What assistive technology hears is whether the popup is shown. In library mode, data-open is the optimistic state: it flips at the click, while an open that waits for an action or for content is still pending. Style click feedback with [data-open] and [data-pending], never with [aria-expanded], which a <button> Trigger does not have. An element that controls a popup without being its invoker, such as the Combobox input, renders aria-expanded from the shown popup too.
One Trigger per Root. The library anchors the popup to its Trigger or returns focus to it, so a Root has one. A second Trigger in the same Root is not supported (development warning); use a Root per trigger.
Foreign invokers. A foreign invoker still works in library mode. An open through it is routed through the library like the Trigger's, so the action runs and the content loads first. A close through it has reason: "activate", because the user acted on a button. It is a request where the component routes it through the library (it cancels the invoker's step and closes after openChangeAction), and a fact reported to onOpenChange where the browser performs it first; each component page says which. A component that keeps focus in its popup or its input does not lose it when you press a foreign invoker: the invoker's own close is the only one.
Example: Popover
A Popover.Trigger renders <button popovertarget> with no aria-expanded. Its styling hook is data-open; on a page that never hydrates, select on the popup that follows it:
.trigger[data-open] { color: var(--accent); }
/* Without JavaScript: the Popup right after the Trigger. */
.trigger:has(+ :popover-open) { color: var(--accent); }A form control built on a real <input> has library-owned state, but the browser flips the input before any JavaScript runs, and after every event react-dom restores a controlled input to its current props. Only the synchronous optimistic state has rendered by then, so such a control renders the input from the optimistic value. That is a correctness requirement: an input driven by committed state would snap back right after the click and stay wrong for as long as the action runs. As a consequence the native pseudo-class (:checked) and the data attribute agree, and assistive technology hears the new state at once.
Example: Switch
A Switch renders <input type="checkbox" role="switch"> with checked={optimistic}, so :checked and data-checked agree from the click on.
The browser can still change a native input without a click the library sees. Each case is a regular dispatch with details.reason === "platform", and afterwards the DOM follows the decision:
form.reset(), or React's automatic reset after a successful <form action>. Uncontrolled, the target is the latest default value; controlled, the browser's mount-time value is offered to the parent, which adopts it or not.A fourth kind of state is consumer-owned and mirrored: the parent derives it, there is no default and no action, and the library only writes it to the DOM after every commit. Where the browser clears it on a click, the library stops writing it while an action is pending.
Example: Checkbox
indeterminate is derived by a "select all" parent from its rows. The library writes the DOM property after every commit and suspends it while an action is pending, because the browser clears it on the click.