Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow layout to be a list of components. #2795

Merged
merged 6 commits into from
Mar 21, 2024
Merged

Allow layout to be a list of components. #2795

merged 6 commits into from
Mar 21, 2024

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Mar 13, 2024

Add the ability to set the layout as a list of components.

Example:

from dash import html, dcc, Input, Output, Dash

app = Dash()

app.layout = [
    html.Div("one", id="one"),
    html.Div("two", id="two"),
]

Co-authored-by: Nathan Drezner <[email protected]>
@AnnMarieW
Copy link
Collaborator

Just curious about the purpose of this PR.
So all this does is to make it unnecessary to use html.Div( ) as the container of app.layout? What's the advantage?

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Mar 14, 2024

@AnnMarieW

So all this does is to make it unnecessary to use html.Div( ) as the container of app.layout?

Yes that is all it does, reduce the number of characters and remove a mostly useless div in many cases. 🙂

@ndrezn
Copy link
Member

ndrezn commented Mar 14, 2024

The main advantage is that we can make a lot of our introductory documentation easier to understand for folks with a Python background but with no HTML background.

@AnnMarieW
Copy link
Collaborator

To me, it seems like it's just another rule to learn. You need to use a component everywhere except with top level of app.layout? You can't get too far in dash with using html components.

@alexcjohnson
Copy link
Collaborator

You can also think of it as changing from one existing rule to another - now layout looks like a children prop

Copy link
Member

@ndrezn ndrezn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I see @AnnMarieW 's point as a "new rule" I think generally this introduces better parity with children, and to me more importantly means that the "Hello World!" Dash examples do not require html.Div but require instead the far more understandable Python list -- ofc you can always do it the traditional way but it'll be a nice simplication of our early docs that I expect won't take much away in terms of pedagogy (hopefully soon we can come to a place where Dash devs don't need to learn HTML concepts to build cool projects!).

Nice work Phillipe and nice test as well! 💃

@T4rk1n T4rk1n merged commit f7f8fb4 into dev Mar 21, 2024
3 checks passed
@T4rk1n T4rk1n deleted the feat/list-as-layout branch March 21, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants