Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

Allow specifying width for "card" stylekit class #468

Closed arcanaxion closed 5 days ago

arcanaxion commented 1 year ago

Description Creating a part with the "card" class occupies the full horizontal space. Is there a way to specify the width of the card?

Currently, I can think of doing this by wrapping it in a layout block like so:

from taipy.gui import Gui, Markdown

md = Markdown("""
<|layout|columns=15rem|

<|card|

Card content              

|>

|>
""")

Gui(md).run()

Acceptance Criteria

FredLL-Avaiga commented 9 months ago

I think that's the plan: use a layout :-)

jrobinAV commented 5 months ago

Is it still relevant in the latest versions of Taipy?

arcanaxion commented 5 months ago

Is it still relevant in the latest versions of Taipy?

I think it could still use improvements.

From my understanding, cards currently take up the full width of its container, and the height is based on height taken by the elements within the card. Half the time, this "default" works — notably when I'm just grouping a bunch of controls to have the same background.

But often I need the card's width to be just enough to fit its content (like how it currently works in height). An example use case is when I'm using cards to show some metric/KPI. Rather than wrap the card in a single-column layout block just so I can specify width, it'd be easier if I could do it directly with the card. Or even better, if I could do something like <|card|width=fit-content|> and it'd be just the right width to fit the metric etc.