When restoring persisted panel layouts, there is currently a client-side layout shift between the server-rendered and hydrated states. This occurs because panel sizes are restored only after the client JS runs, rather than before the initial paint.
Proposal
If flexGrow were moved to a CSS variable, panel sizes could be restored before hydration.
Specifically:
- A small blocking inline script could read persisted panel sizes (from
localStorage).
- The script would then set the CSS variable on the root element (e.g.,
--panel-flex-grow).
- The
PanelGroup would render with the correct flex values immediately, preventing visual jumps.
This approach is somewhat similar to how react-wrap-balancer precomputes text balance client-side before hydration to avoid layout shifts.
@bvaughn What's your opinion on this approach?
When restoring persisted panel layouts, there is currently a client-side layout shift between the server-rendered and hydrated states. This occurs because panel sizes are restored only after the client JS runs, rather than before the initial paint.
Proposal
If flexGrow were moved to a CSS variable, panel sizes could be restored before hydration.
Specifically:
localStorage).--panel-flex-grow).PanelGroupwould render with the correct flex values immediately, preventing visual jumps.This approach is somewhat similar to how react-wrap-balancer precomputes text balance client-side before hydration to avoid layout shifts.
@bvaughn What's your opinion on this approach?