From 5427dd0f5bce222b7f75e0c1ba3ccc1b29e35cc0 Mon Sep 17 00:00:00 2001 From: Dong-hyeon Shin <52447545+qu3vipon@users.noreply.github.com> Date: Sun, 29 Jan 2023 02:21:36 +0900 Subject: [PATCH] Support multiple styles for components (#370) --- pynecone/components/component.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pynecone/components/component.py b/pynecone/components/component.py index 8b436ac55..5f749c6ec 100644 --- a/pynecone/components/component.py +++ b/pynecone/components/component.py @@ -130,9 +130,14 @@ class Component(Base, ABC): del kwargs[key] # Add style props to the component. + style = kwargs.get("style", {}) + if isinstance(style, List): + # Merge styles, the later ones overriding keys in the earlier ones. + style = {k: v for style_dict in style for k, v in style_dict.items()} + kwargs["style"] = Style( { - **kwargs.get("style", {}), + **style, **{attr: value for attr, value in kwargs.items() if attr not in fields}, } )