Installation
Add @nkootstra/block-kit to a React 19 app, with its stylesheet and fonts.
The package needs React 19 or later. It works with any bundler that can import CSS: Vite, Next.js, Remix, Astro and the like.
Install the package
npm install @nkootstra/block-kitpnpm add @nkootstra/block-kityarn add @nkootstra/block-kitbun add @nkootstra/block-kitnub add @nkootstra/block-kitaube add @nkootstra/block-kitImport the stylesheet
Import the styles once, near the root of your app:
import "@nkootstra/block-kit/styles.css";The stylesheet only styles elements inside the components it ships, and rolls them back to the browser’s defaults first. Global styles in your app, such as Tailwind’s preflight, don’t change how blocks render.
Load the fonts
Slack sets text in Lato and code in Roboto Mono. Slack’s own font files aren’t redistributable, so install the open-source builds from Fontsource:
npm install @fontsource/lato @fontsource/roboto-monopnpm add @fontsource/lato @fontsource/roboto-monoyarn add @fontsource/lato @fontsource/roboto-monobun add @fontsource/lato @fontsource/roboto-mononub add @fontsource/lato @fontsource/roboto-monoaube add @fontsource/lato @fontsource/roboto-monoimport "@fontsource/lato/400.css";
import "@fontsource/lato/400-italic.css";
import "@fontsource/lato/700.css";
import "@fontsource/lato/900.css";
import "@fontsource/roboto-mono/400.css";Render a message
import { BlockKitProvider, Message } from "@nkootstra/block-kit";
export function App() {
return (
<BlockKitProvider>
<Message
blocks={[
{ type: "section", text: { type: "mrkdwn", text: "*Hello* from Block Kit :wave:" } },
]}
/>
</BlockKitProvider>
);
}Optional peer dependencies
| Package | When you need it |
|---|---|
@slack/web-api |
To resolve user, channel and usergroup names with @nkootstra/block-kit/web-api. |
Entry points
| Import | What it contains |
|---|---|
@nkootstra/block-kit |
Components, the provider, hooks and payload builders. |
@nkootstra/block-kit/styles.css |
The stylesheet. |
@nkootstra/block-kit/mrkdwn |
The mrkdwn parser, without React. See mrkdwn. |
@nkootstra/block-kit/transport |
Sends interactions to your app’s request URL from the browser. See Connecting your app. |
@nkootstra/block-kit/server |
Signs and relays interactions to your app from your server. |
@nkootstra/block-kit/web-api |
Resolvers backed by the Slack Web API. |
