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.
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
planandtask_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_submissionandblock_suggestionpayloads, 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
Installation
Add the package, its stylesheet and fonts.
Quickstart
Render your first message and handle a button click.
Examples
Approval requests, alerts, polls, forms and Home tabs, ready to copy.
Blocks
Every block, with live examples you can copy.
Interactivity
Handle actions, open modals and update messages.
Guides
Every task-by-task guide, from mentions to theming and server rendering.
Reference
The full API: provider props, components, hooks and payloads.
Block Kit editor
Let your users edit Block Kit JSON and see the Slack preview as they type.
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.
