Definition¶
ContentArea marks the main content region of a structured layout. It is a container for page content beside or below shell elements such as Sidebar, Header, or split panes.
Scope¶
Use ContentArea for the primary workspace of a page. It is a general container, not a layout-direction primitive. The first child should normally be a layout component with explicit child distribution semantics, such as Column, Row, ScrollArea, or Splitter.
Use Column for vertical stacking inside the workspace, Row for horizontal distribution, and ScrollArea when content can overflow. This keeps the behavior predictable across desktop and web clients.
Properties¶
| Property | Type | Default | Notes |
|---|---|---|---|
children |
list[str | Component] |
[] |
Content rendered in the main area. Prefer a single explicit layout container as the first child. |
stretch |
bool |
false |
Lets the content area fill available space. |
style |
string |
None |
Common component style property. Supports direct property updates. |
Static ContentArea¶
body = sdk.ui.Column("content_body", ["main_text"])
builder.add(body)
content = sdk.ui.ContentArea("content_area", [body.id])
content.set_property("stretch", True)
builder.add(content)- kind: ContentArea
id: content_area
stretch: true
children:
- kind: Column
id: content_body
children:
- main_textFirst-Level Layout¶
ContentArea should not be used as the component that decides whether repeated children flow vertically or horizontally. Put a layout container at the first level and update that container when content changes dynamically.
body = sdk.ui.Column("content_body", ["row_1", "row_2"])
body.set_property("stretch", True)
builder.add(body)
content = sdk.ui.ContentArea("content_area", [body.id])
content.set_property("stretch", True)
builder.add(content)With ScrollArea¶
Use this pattern when the main content can be taller than the available space.
stack = sdk.ui.Column("content_stack", ["row_1", "row_2"])
builder.add(stack)
scroll = sdk.ui.ScrollArea("content_scroll", [stack.id])
scroll.set_property("stretch", True)
scroll.set_property("scroll_x", False)
builder.add(scroll)
content = sdk.ui.ContentArea("content_area", [scroll.id])
content.set_property("stretch", True)
builder.add(content)- kind: ContentArea
id: content_area
stretch: true
children:
- kind: ScrollArea
id: content_scroll
stretch: true
scroll_x: false
children:
- kind: Column
id: content_stack
children:
- row_1
- row_2Store Binding¶
Bind style when the content area state is driven by the page store.
content = sdk.ui.ContentArea("content_area_store", [body.id])
content.set_property("stretch", True)
content.set_property(
"style",
bound.store("/components_test/contentarea/style", scope="page", default=""),
)
builder.add(content)- kind: ContentArea
id: content_area_store
stretch: true
style: {type: store, scope: page, path: /components_test/contentarea/style, default: ""}
children:
- content_bodyData Model Binding¶
Use data-model binding when the content area style comes from the surface data model.
content = sdk.ui.ContentArea("content_area_data", [body.id])
content.set_property("stretch", True)
content.set_property(
"style",
bound.data("/components_test/contentarea_model/style", default=""),
)
builder.add(content)- kind: ContentArea
id: content_area_data
stretch: true
style: "@data/components_test/contentarea_model/style"
children:
- content_bodyProperty Updates¶
Declare capabilities before updating style directly.
content = sdk.ui.ContentArea("content_area_live", [body.id])
content.set_property("stretch", True)
content.allow("style.set")
builder.add(content)- kind: ContentArea
id: content_area_live
stretch: true
capabilities: [style.set]
children:
- content_bodyThe action can update store, data model, and live content-area properties:
return sdk.effects.respond(
sdk.effects.ui_property_update("content_area_live", "style", next_style, surface_id=surface_id),
)Dynamic Children¶
When the main workspace changes without replacing the whole page, update the first-level layout container inside ContentArea. Do not append repeated rows directly to ContentArea.children unless the client-specific layout behavior is acceptable for that use case.
body = sdk.ui.Column("content_area_dynamic_body", ["row_1", "row_2"])
body.set_property("stretch", True)
body.allow("children.append", "children.remove")
builder.add(body)
content = sdk.ui.ContentArea("content_area_dynamic", [body.id])
content.set_property("stretch", True)
builder.add(content)
# In the action:
return sdk.effects.respond(
sdk.effects.ui_collection_append("content_area_dynamic_body", "children", row_component_dict, surface_id=surface_id),
)- kind: ContentArea
id: content_area_dynamic
stretch: true
children:
- kind: Column
id: content_area_dynamic_body
stretch: true
capabilities: [children.append, children.remove]
children:
- kind: Text
id: content_area_dynamic_row_1
text: "Dynamic row 1"
- kind: Text
id: content_area_dynamic_row_2
text: "Dynamic row 2"Visibility And Permissions¶
show_if, hide_if, and required_permissions are available on ContentArea.
content.set_show_if({
"conditions": [
{"left": bound.store("/components_test/visibility/contentarea_show", scope="page", default=True), "op": "==", "right": True}
]
})
content.set_hide_if({
"conditions": [
{"left": bound.store("/components_test/visibility/contentarea_hide", scope="page", default=False), "op": "==", "right": True}
]
})
content.set_required_permissions(["components.layout.view"])- kind: ContentArea
id: content_area_show_if
show_if:
conditions:
- left: {type: store, scope: page, path: /components_test/visibility/contentarea_show, default: true}
op: "=="
right: true
children:
- content_body
- kind: ContentArea
id: content_area_hide_if
hide_if:
conditions:
- left: {type: store, scope: page, path: /components_test/visibility/contentarea_hide, default: false}
op: "=="
right: true
children:
- content_body
- kind: ContentArea
id: content_area_required_permissions
required_permissions: [components.layout.view]
children:
- content_bodyNotes¶
ContentAreaidentifies the main workspace; it is not a layout-direction or scrolling primitive.- Put a direction-aware layout container as the first child when repeated content must flow predictably.
- Put
ScrollAreainsideContentAreafor long content. - Use
stretch: truewhenContentAreamust fill the remaining width or height in a shell layout. - Keep inner wrappers at
min-height: 0when combiningContentAreawith bounded-height layouts and scroll areas.