Skip to main content

Using Blocks

Blocks are the fundamental visual units of a Slack message. Each block type renders as a different UI component (a section of text, a header, a divider, an image, a row of buttons, and so on). A Message is composed of one or more blocks, rendered top-to-bottom.

This page walks through every block type supported by slackblocks, with:

  • A short description of what the block is for.
  • The slackblocks code to construct it in your selected language.
  • The JSON payload that's produced.
  • A visual example. PNG images are historical Slack captures; SVG images are illustrative local previews, not proof of current Slack rendering. See validation boundaries for dated receiving-path evidence.

For the reverse mapping — looking up a class by name — see the Blocks reference. For interactive UI bits (buttons, menus, date pickers) that go inside blocks, see Elements.

Ownership and edits​

Models are mutable. Collection coercion can retain the caller's list and nested model references, so changing a source list can change a later serialization. Build a fresh model, or copy application inputs, when personalizing a reusable template.

These guarantees concern modeled fields, not arbitrary foreign objects or unchecked extension values. Application state, callback revisions and database records remain application-owned.

Omission and defaults​

Leave an optional argument or setter unused to request omission. Required fields, defaults and normalization are field-specific; inspect the final wire payload when an explicit zero, false or empty collection matters.

Omitted block IDs are generated. Some serializers retain legacy truthiness normalization: DateTimePicker(initial_datetime=0) omits initial_date_time even though the model attribute remains zero. Pin block IDs in tests and inspect serialized fields where zero or False matters.

See Validation boundaries for local checks and application-owned constraints. Existing defaults are retained for compatibility.

Layout grids​

See Layouts for rows, weighted widths, alignment, supported children, nesting and fallback behavior, with a diagram and a basic executable example in your selected language.

Section Block​

A section is the most versatile block. It shows text, a two-column grid of fields, or both, and can carry one interactive accessory such as a button, menu, or image.

Provide text, fields, or both. text allows up to 3,000 characters, and fields allows up to 10 items of up to 2,000 characters each.

from slackblocks import CheckboxGroup, Option, SectionBlock

SectionBlock(
text="This is a section block with a checkbox accessory.",
block_id="fake_block_id",
accessory=CheckboxGroup(
action_id="checkboxes-action",
options=[
Option(
text="*Your Only Option*",
value="option_one"
)
]
)
)

Rich Text Block​

Rich text carries formatted content built from sections, lists, preformatted code, and quotes. Inline elements add bold, italic, strikethrough, and code styling, along with links, emoji, and user, channel, or user group mentions.

Required: elements.

from slackblocks import RichTextBlock, RichTextSection, RichText

RichTextBlock(
RichTextSection(
[
RichText(
"You 'bout to witness hip-hop in its most purest\n",
bold=True,
),
RichText(
"Most rawest form, flow almost flawless\n",
strike=True,
),
RichText(
"Most hardest, most honest known artist\n",
italic=True,
),
]
),
block_id="fake_block_id",
)

Header Block​

A header shows large, bold plain text that introduces a group of blocks. Languages with string coercion convert plain strings to Slack plain_text objects. APIs with explicit text roles, including Haskell, require their native plain-text constructor.

Required: text (up to 150 characters).

from slackblocks import HeaderBlock

HeaderBlock(
"This is a header block",
block_id="fake_block_id",
)

Markdown Block​

Slack added the markdown block type in 2024, primarily for AI / agentic apps. Unlike the mrkdwn text inside a Section Block, MarkdownBlock renders GitHub-flavored Markdown, supporting tables, code blocks, and richer list semantics.

text is required and accepts an empty string locally. The maximum is 12,000 Unicode code points, including the aggregate Markdown text in a complete message. A constructed block alone does not establish that Slack will accept the final payload.

from slackblocks import MarkdownBlock

MarkdownBlock(
text="**Hello!** Markdown blocks support _GitHub-flavored_ syntax.",
block_id="fake_block_id",
)

See the Slack reference for the supported Markdown features.

Image Block​

An image block displays a standalone image from a URL, with alternative text for screen readers and an optional plain-text title.

Required: alt_text (up to 2,000 characters) and exactly one image source: image_url (up to 3,000 characters) or a slack_file object. Use the native SlackFile composition object for an existing Slack file; see Slack’s image-block reference.

from slackblocks import ImageBlock

ImageBlock(
image_url="https://api.slack.com/img/blocks/bkb_template_images/beagle.png",
alt_text="a beagle",
title="dog",
block_id="fake_block_id",
)

Input Block​

An input block pairs a label with one input element, such as a text input, select menu, or date picker, to collect a value from the user. Input blocks are most common in modals, and can also appear in messages and App Home.

Required: label (up to 2,000 characters) and element. Set optional to allow submission without a value, and dispatch_action to receive an interaction payload as the value changes.

from slackblocks import InputBlock, Text, TextType, PlainTextInput

InputBlock(
label=Text("Label", type_=TextType.PLAINTEXT, emoji=True),
hint=Text("Hint", type_=TextType.PLAINTEXT, emoji=True),
element=PlainTextInput(action_id="action"),
block_id="fake_block_id",
optional=True,
)

Divider Block​

A divider draws a horizontal rule between blocks, much like an HTML <hr> element.

No fields are required.

from slackblocks import DividerBlock

DividerBlock(block_id="fake_block_id")

File Block​

A file block represents a remote file registered with files.remote.add. Slack returns this block in retrieved messages; apps cannot post a FileBlock directly to a message, modal or App Home. Register and share the remote file using Slack’s file APIs, then read back the resulting message. Construction support represents that returned JSON and does not upload or share a file. See live prerequisites and Slack’s FileBlock restriction.

Required: external_id. source defaults to remote, the only value Slack currently accepts.

from slackblocks import FileBlock

FileBlock(
external_id="external_id",
block_id="fake_block_id",
)

Context Block​

A context block shows small, secondary images and text, such as an author, a timestamp, or a status line beneath other content.

Required: elements (up to 10 images or text objects).

from slackblocks import ContextBlock, Text

ContextBlock(
elements=[
Text("Hello, world!"),
],
block_id="fake_block_id"
)

Actions Block​

An actions block holds a row of interactive elements, such as buttons, select menus, overflow menus, checkboxes, and date pickers.

Required: elements (up to 25 elements).

from slackblocks import ActionsBlock, CheckboxGroup, Option

ActionsBlock(
block_id="fake_block_id",
elements=CheckboxGroup(
action_id="actionId-0",
options=[
Option(text="*a*", value="a", description="*a*"),
Option(text="*b*", value="b", description="*b*"),
Option(text="*c*", value="c", description="*c*"),
],
),
)

Table Block​

A table block lays out raw text, numeric and rich text cells in rows and columns. Optional column_settings control each column's alignment and whether its text wraps.

Required: rows. Plain tables allow rows of different lengths. column_settings may describe only the leading columns; remaining columns use Slack’s defaults. Use null entries to skip individual columns without shifting later settings. These entries count toward the 20-setting limit. Data tables have separate rectangular-row rules.

For example, [null, {"align": "left"}] leaves the first column at Slack’s defaults and aligns the second to the left. The native examples below produce that sparse list.

Slack documents null entries, but the stress workspace’s blocks.validate endpoint rejected them on 2026-11-14. Slackblocks preserves the documented wire form consistently across all ten languages. Until the receiving path supports it, use {} (a default ColumnSettings value) instead of null to retain a skipped position; live rendering of sparse settings has not been verified.

Shared contract 1.6.0 (Slackblocks 4.0.0)

All ten native APIs accept RawNumber cells with both a numeric value and displayed text. The example below displays 42 items while preserving the numeric value 42. Numeric display labels must be non-empty in both plain and data tables. Numeric values must be finite JSON numbers.

Sparse settings use None in Python, null in TypeScript/Java/C#/PHP, nil in Go/Ruby/Elixir, Option<ColumnSettings> in Rust and Maybe ColumnSettings in Haskell. Haskell callers upgrading from 3.x must wrap existing entries in Just; Rust getters now expose optional entries, while setters still accept ordinary settings.

Displayed cell text is limited to 10,000 Unicode code points per table and across plain tables in a message, including attachments, containers and layout fallbacks. This counts rich-text text/link labels and numeric display text; sorting values, URLs and message metadata do not consume the budget. Data-table and Markdown budgets are separate. Previously accepted oversized tables now fail local validation.

Slack’s table reference specifies these limits. Structural checks on 2026-11-14 accepted 10,001-character inputs; the library follows the stricter published contract. Those checks establish neither message delivery nor rendering. This support is included in 4.0.0 and is absent from 3.2.0. See the 4.0.0 migration notes before upgrading.

from slackblocks import (
ColumnSettings,
RawNumber,
RichText,
RichTextLink,
RichTextSection,
TableBlock,
)

TableBlock(
block_id="fake_block_id",
column_settings=[
None,
ColumnSettings(align="left"),
],
rows=[
[
RichTextSection(
elements=[RichText(text="Header 1", bold=True)],
),
RichTextSection(
elements=[RichText(text="Header 2", bold=True)],
),
],
[
RawNumber(value=42, text="42 items"),
RichTextSection(
elements=[
RichTextLink(
url="https://slack.com",
text="Datum 2",
)
],
),
],
],
)

Video Block​

Embeds a video from a Slack-supported provider such as YouTube or Vimeo. Use plain-text values for title and description; APIs that accept strings coerce them, while explicitly typed APIs require their native plain-text values.

Required: alt_text, thumbnail_url, title, video_url. Slack restricts which domains may be embedded — supplying an unsupported URL will produce a Slack API error rather than a local construction error. Python calls that category InvalidUsageError; each language uses its native error API.

from slackblocks import VideoBlock

VideoBlock(
alt_text="Use the Events API to create a dynamic App Home",
block_id="fake_block_id",
thumbnail_url="https://i.ytimg.com/vi/8876OZV_Yy0/hqdefault.jpg",
title="Use the Events API to create a dynamic App Home",
video_url="https://www.youtube.com/embed/8876OZV_Yy0?feature=oembed&autoplay=1",
description="Slack sure is nifty!",
title_url="https://www.youtube.com/watch?v=8876OZV_Yy0",
)

See the Slack reference for the full list of optional fields and provider requirements.

Alert Block​

Alerts add a severity-labelled notice to a modal.

Required: text (up to 200 characters). level sets the severity: default, info, warning, error, or success.

from slackblocks import AlertBlock

AlertBlock(
"The deployment needs attention.",
level="warning",
block_id="fake_block_id",
)

Card Block​

Cards combine text, images, Slack-provided icons, and up to three buttons in a compact panel.

Slack controls action placement: buttons align right with primary last. With two buttons, danger stays in that group before the other button; with three, it sits at the far left of the card. Slackblocks preserves the supplied array order. See Card actions for tested code and rendered two- and three-button examples.

Provide at least one of hero_image, title, actions, or body. An image icon and a slack_icon cannot be combined.

from slackblocks import Button, CardBlock, SlackIcon

CardBlock(
title="Build complete",
body="Version 2.1.0 is ready to deploy.",
slack_icon=SlackIcon("rocket"),
actions=Button("Open build", "open_build"),
block_id="fake_block_id",
)

A carousel presents between one and ten cards in a horizontally scrolling collection.

Required: elements.

from slackblocks import CardBlock, CarouselBlock

CarouselBlock([
CardBlock(title="First result", block_id="card_1"),
CardBlock(title="Second result", block_id="card_2"),
], block_id="fake_block_id")

Container Block​

Containers group up to ten related child blocks under a plain-text or rich-text title.

Required: child_blocks, plus either title or rich_text_title.

from slackblocks import ContainerBlock, SectionBlock

ContainerBlock(
title="Deployment summary",
child_blocks=[
SectionBlock("All systems operational.", block_id="child_1"),
],
has_header_divider=True,
block_id="fake_block_id",
)

Context Actions Block​

Context actions hold feedback controls or compact icon buttons. Slack currently offers the trash icon for icon buttons.

Required: elements (up to 5).

from slackblocks import ContextActionsBlock, FeedbackButton, FeedbackButtons

ContextActionsBlock([
FeedbackButtons(
positive_button=FeedbackButton("Good", "positive"),
negative_button=FeedbackButton("Bad", "negative"),
action_id="response_feedback",
)
], block_id="fake_block_id")

Data Table Block​

Data tables support raw text, sortable raw numbers, and rich-text body cells. They require a header plus at least one data row.

Required: rows and caption. Tables hold up to 200 data rows, every row must have the same number of cells, and all cell text together is limited to 20,000 characters.

from slackblocks import DataTableBlock, RawNumber, RawText

DataTableBlock(
caption="Team scores",
rows=[
[RawText("Name"), RawText("Score")],
[RawText("Alice"), RawNumber(42, "42")],
],
block_id="fake_block_id",
)

Data Visualization Block​

Slack can render pie charts or axis-based bar, area, and line charts directly from Block Kit data.

Required: title (up to 50 characters) and chart.

from slackblocks import ChartSegment, DataVisualizationBlock, PieChart

DataVisualizationBlock(
title="Incidents by severity",
chart=PieChart([
ChartSegment("High", 3),
ChartSegment("Low", 12),
]),
block_id="fake_block_id",
)

Task Card Block​

Task cards show a task's state, optional rich-text details or output, and the URL sources used to produce it.

Required: task_id, title, and status.

from slackblocks import TaskCardBlock, URLSource

TaskCardBlock(
task_id="weather_1",
title="Fetch weather data",
status="complete",
sources=[URLSource("https://weather.com/", "weather.com")],
block_id="fake_block_id",
)

Plan Block​

For message delivery, use the plan as the top-level representation of its tasks. Put a standalone TaskCardBlock in a separate message instead of combining it with a plan. On 13 October 2026, minimal native Python messages containing only a plan or only a completed task both posted successfully. The combined message was rejected with “Plan block and task blocks are mutually exclusive”, although blocks.validate accepted all three. This is a message-delivery compatibility recipe; these controls do not establish a restriction for other surfaces.

Give separately rendered rich-text details and output fresh block IDs, including when their text is identical. Reconstruct each native rich-text value with a distinct ID instead of reusing one object. The Slack plan example reuses a nested ID. Paired minimal message controls rejected reuse between one task's details and output, both within a plan and in a standalone task, while distinct IDs succeeded. Structural validation accepted all four controls. The observations are recorded in the sanitized SB-016 evidence. They do not establish that every recursive block context shares one ID namespace. The native examples below deliberately use one plan and unique task IDs.

A plan groups task cards. slackblocks automatically renders nested tasks in Slack's plan-specific wire format.

Required: title and tasks.

from slackblocks import PlanBlock, TaskCardBlock

PlanBlock(
title="Release plan",
tasks=[
TaskCardBlock("test", "Run the test suite", status="complete"),
TaskCardBlock("deploy", "Deploy the release", status="pending"),
],
block_id="fake_block_id",
)

Higher-Level Components​

Compose ordinary Python block lists and ContainerBlock values for reusable layouts. Python does not currently expose the named Paginator and Accordion helpers. Keep paging state in the application. Use block_kit_builder_url for preview links; see Utilities and Blocks.

Component helpers compose blocks and controls. They do not store pagination state, process callbacks, schedule work or grant Slack permissions. Recompose each payload from application state and validate its receiving surface after expanding helpers.