Skip to content

Is it possible to add classes and props as object? #561

Closed Answered by falkoschindler
DamianSz2000 asked this question in Q&A
Discussion options

You must be logged in to vote

There are a couple of ways to do this:

  1. Use Python's line continuation \:

    with ui.column() \
            .classes("w-full h-full") \
            .props("blah blah"):
        ...
  2. Break the builder-pattern into multiple lines:

    with ui.column() as column:
        column.classes("w-full h-full")
        column.props("blah blah")
        ...
  3. Keep the classes and props in strings:

    classes = "w-full h-full"
    props = "blah blah"
    with ui.column().classes(classes).props(props):
        ...    

Apart from that we are already working on an improved Tailwind API (#362). This will allow you keep the Tailwind style definition in an object and apply it to different objects, like:

style = Tailwind().width('full').height('full')

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by falkoschindler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #559 on March 19, 2023 14:45.