Skip to main content

Weighted layout grid

Available from Slackblocks 3.2.0. Arrange service names and status text in two rows, using a 3:1 width ratio and an explicit linear fallback. The label is shown as bold text, not a heading. These examples construct a block; they do not send a message.

Output

Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.

Service status
API
Healthy
Worker
Delayed
Linear fallback
API: Healthy; Worker: Delayed
Serialized output
{
"type": "layout",
"block_id": "service-layout",
"label": "Service status",
"rows": [
{
"items": [
{
"block": {
"type": "section",
"block_id": "api",
"text": {
"type": "plain_text",
"text": "API"
}
},
"width": "wide"
},
{
"block": {
"type": "section",
"block_id": "api-status",
"text": {
"type": "plain_text",
"text": "Healthy"
}
},
"width": "narrow",
"horizontal_alignment": "end"
}
]
},
{
"items": [
{
"block": {
"type": "section",
"block_id": "worker",
"text": {
"type": "plain_text",
"text": "Worker"
}
},
"width": "wide"
},
{
"block": {
"type": "section",
"block_id": "worker-status",
"text": {
"type": "plain_text",
"text": "Delayed"
}
},
"width": "narrow",
"horizontal_alignment": "end"
}
]
}
],
"is_label_visible": true,
"grid_lines": "rows",
"fallback": [
{
"type": "section",
"block_id": "status-fallback",
"text": {
"type": "plain_text",
"text": "API: Healthy; Worker: Delayed"
}
}
]
}
from slackblocks import LayoutBlock, LayoutRow, LayoutItem, PlainText, SectionBlock


def section(text, identifier):
return SectionBlock(text=PlainText(text), block_id=identifier)


layout = LayoutBlock(
label="Service status", block_id="service-layout", is_label_visible=True,
grid_lines="rows",
rows=[
LayoutRow(items=[
LayoutItem(block=section("API", "api"), width="wide"),
LayoutItem(block=section("Healthy", "api-status"), width="narrow", horizontal_alignment="end"),
]),
LayoutRow(items=[
LayoutItem(block=section("Worker", "worker"), width="wide"),
LayoutItem(block=section("Delayed", "worker-status"), width="narrow", horizontal_alignment="end"),
]),
],
fallback=[section("API: Healthy; Worker: Delayed", "status-fallback")],
)
print(layout)

Layout and fallback behavior​

  • Rows contain one to three items; a layout has one to five rows. narrow, standard and wide have weights 1, 2 and 3. An omitted width is standard; omitted alignment fills the cell.
  • rows draws the outer border and horizontal row separators. outer draws only the border; none draws neither. There are no vertical grid lines.
  • Fallback is a separate linear representation for clients that cannot render layouts. The library preserves omission and explicit empty arrays; it does not invent a fallback. Put essential information in the message's top-level text too.
  • Hidden labels are not accessible names. Preserve meaningful source order, do not convey status through colour alone, and test your app with assistive technology. Slack may wrap cells on narrow clients; this local preview is illustrative.

See Layouts and validation boundaries before composing larger grids. Older-client fallback and mobile/screen-reader behavior are documented contracts, not guarantees established by this preview.