Skip to content

[Feature Request] Improve persisted client side rendering #520

@isBatak

Description

@isBatak

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions