Base Component
components.base
Component
Unified DOM-like base class for all UI elements.
The component class represents a node in the UI tree. It can be instantiated and manipulated dynamically before being rendered into HTML.
Attributes:
| Name | Type | Description |
|---|---|---|
uid |
str
|
Uniquely identifies the element. Essential for HTMX targeting. |
classes |
str
|
Tailwind utility classes applied to the component. |
role |
List[str]
|
Access control roles. Components automatically prune if the current user lacks the required role. |
children |
List[Component]
|
Nested child UI components. |
key |
str
|
Binds the component to a context dictionary key or model field. |
static_value |
Any
|
Bypasses context value lookup to force a static render value. |
url |
Callable | str
|
An explicit URL, or a callable resolving to a URL. |
Source code in components/base.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
append(target_uid, new_component)
Find a target node in the tree and append a child to it.
Source code in components/base.py
141 142 143 144 145 146 147 | |
build()
Hook for dynamic structures (like Layouts or Forms) to construct their
internal node hierarchy immediately before rendering.
Returns the root component of the built tree (usually self).
Source code in components/base.py
167 168 169 170 171 172 173 | |
check(request=None, **kwargs)
Evaluate if the current request satisfies the component's role requirements.
If this returns False, the component and all descendants are excluded from rendering.
Source code in components/base.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
find(target_uid)
Search this node and all descendants for a UID.
Source code in components/base.py
91 92 93 94 95 96 97 98 99 100 101 | |
find_parent(target_uid)
Find the immediate parent of a specific UID.
Source code in components/base.py
103 104 105 106 107 108 109 110 111 | |
remove(target_uid)
Find the parent of a target node and remove the target from its children.
Source code in components/base.py
149 150 151 152 153 154 155 | |
render(**kwargs)
The primary entry point for converting the component tree into an HTML string.
Safely enforces role checks before delegating to render_html.
Source code in components/base.py
64 65 66 67 68 69 70 71 72 | |
render_partial(target_uid, **kwargs)
Recursively scans the tree for a node matching the target_uid.
If found, performs an isolated render of only that node and its children.
Source code in components/base.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
replace(target_uid, new_component)
Find a target node and replace it completely in its parent's list.
Source code in components/base.py
157 158 159 160 161 162 163 164 165 | |