Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Condition

Renders a different set of blocks depending on the client surface that's viewing them.

condition picks one branch of blocks to render based on client conditions, and falls back to default when none match. It’s a library-invented construct for previewing client-conditional payloads; Slack doesn’t document a public condition block type.

Your AppAPP
Desktop branch

Since this renderer only ever simulates Slack’s desktop client, the example above always shows the desktop branch, the same way it would look in Slack’s own Builder preview.

Fields

PropType
typestring

Always `condition`.

Typestring
cases?{ conditions: ConditionClause[]; blocks: Block[] }[]

Branches, tested in order. The first case whose conditions all match wins, and its `blocks` render.

Type{ conditions: ConditionClause[]; blocks: Block[] }[]
default?Block[]

Blocks rendered when no case matches.

TypeBlock[]

ConditionClause

PropType
typestring

The condition kind. Only `"client"` is evaluated; any other value never matches.

Typestring
op?"=" | "!="

Comparison against `value`. Omitted is treated the same as `"="`.

Type"=" | "!="
Default"="
value?string

The client to compare against, e.g. `"desktop"`, `"ios"`, `"android"`.

Typestring

Examples

Client branches with a default

The preview above defines a branch per client plus a default, and only the desktop branch renders.

Negated condition

Your AppAPP
Desktop (default)

op: "!=" matches every client except the given value. Here the desktop client never matches, so the default branch renders instead.

Was this page helpful?