Interact with `Layout` defined in another file
In a file with a defined
Page
solara component, I can import a defined Layout
specified in another file. Just importing is enough to render the page in that layout. However, it does not seem to allow for interacting with the layout; i.e. I cannot pass a "page title" or something similar. I'm curious if it's possible to interact with the Layout
beyond being able to define the children, or if perhaps I should be inspecting the children and pulling out which elements I want for particulars parts of the layout?
For example:
3 Replies
In React this can be done with portals, and it seems that Reacton also supports this as an undocumented feature. You can see an example in solara.AppLayout, which allows to modify AppBar and AppBarTitle content from any component:
https://github.com/widgetti/solara/blob/9e3cdae574a3534d940131504c535ee7a5f59ee0/solara/components/applayout.py#L33C7-L33C20
solara/components/applayout.py
line 33
Hi Egor, nice to see you found the portals 🙂 I don't think they are need for this.
This would be a nice pattern I think: