Skip to content

Labels

components.labels

Text label components suitable for displaying read-only data.

InlineLabel

Bases: Label

A label rendered inline with its children.

Source code in components/labels.py
14
15
16
17
18
19
20
21
22
23
24
class InlineLabel(Label):
    """A label rendered inline with its children."""
    def render_html(self, **kwargs):
        return f"""
        <div id="{self.uid}" class="flex gap-2 {self.classes}">
            <span class="text-primary font-bold">
                {self.title}:
            </span>
            {"".join([component.render(**kwargs) for component in self.children])}
        </div>
        """

Label

Bases: Component

Base text label component.

Source code in components/labels.py
 7
 8
 9
10
11
class Label(Component):
    """Base text label component."""
    def __init__(self, title: str, **kwargs):
        super().__init__(**kwargs)
        self.title = title

NewlineLabel

Bases: Label

A label rendered above its children on a new line.

Source code in components/labels.py
27
28
29
30
31
32
33
34
35
36
class NewlineLabel(Label):
    """A label rendered above its children on a new line."""
    def render_html(self, **kwargs):
        return f"""
        <div id="{self.uid}" class="{self.classes}">
            <span class="text-primary font-bold">
                {self.title}:</span>
            <div>{"".join([component.render(**kwargs) for component in self.children])}</div>
        </div>
        """