Style Object
The StyleObject class is used to create reusable styles for components.
It is a dictionary-like object that can be used to store CSS properties and values.
Usage
To create a new style object, create a new instance of the StyleObject class from seamless.styling.
Creating a style object
from seamless.styling import StyleObject
style = StyleObject(
background_color="red",
color="white"
)
This will create a style object with the properties background_color and color.
To use the style object, pass it as the style prop to the component.
Using a style object
from seamless import Component, Div
class App(Component):
def render(self):
return Div(style=style)(
"Hello, world!"
)
This will create an inline style with the properties from the style object.
Style object output
<div style="background-color: red; color: white;">Hello, world!</div>