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

Slack Block Kit for React

Render Slack Block Kit JSON in React, pixel-for-pixel the way Slack does.

@nkootstra/block-kit renders the Block Kit JSON your Slack app sends (messages, modals and Home tabs) as React components that look and behave the way they do in Slack.

Your AppAPP
Ada Lovelace requested time off :palm_tree:
Type:
Paid time off
When:
Aug 10 – Aug 13
Hours:
16.0 (2 days)
Remaining balance:
32.0 hours (4 days)
onActionInteract with the preview.

Click a button: the log under the preview shows the action your onAction handler receives, in the same shape Slack sends to your app.

To see your own JSON rendered without installing anything, paste it into the Block Kit playground. It renders messages, modals and Home tabs with this package, shows the payload each click sends, and needs no Slack sign-in.

Why this exists

Slack’s Block Kit Builder only runs inside Slack. When you want to show a message outside of it, such as in a preview in your admin panel, a gallery of templates, an approval queue in your own product, a message editor for your users, or a test harness for your bot, you’d otherwise have to rebuild Slack’s layout rules by hand.

This package does that work for you:

  • Every block and element. Sections, rich text, tables, charts, cards, carousels, inputs, every select menu and picker, including the newer agent blocks such as plan and task_card.
  • Measured against Slack. Each block is compared, pixel by pixel, against captures of Slack’s own rendering. Spacing, fonts, colours, hover and focus states match.
  • Interactive. Buttons, selects, pickers and inputs work. You receive Slack’s block_actions, view_submission and block_suggestion payloads, and can answer them the way your app would: open a modal, update the message, return validation errors.
  • Plugs into your app. Forward interactions to an existing Bolt app with a signed relay, and resolve user and channel mentions from the Slack Web API.

Where to start

See what changed in each release in the changelog, and what to change in your app when you upgrade in Upgrading.

MIT licensed. Not affiliated with Slack. Slack and Block Kit are trademarks of Slack Technologies, LLC.

Last updated on