Skip to content

A concise, and opinionated, syntax for building Slack Block Kit UIs...and other things.

License

Notifications You must be signed in to change notification settings

zholmquist/slack_tools

Repository files navigation

Slack Tools

A concise, and opinionated, syntax for building Slack Block Kit UIs.

Caution

This project is not fully complete, and implementation details are unstable.

Usage

from slack_tools import BlockKit

# Button Action Callback
def greet():
    print('Hello!')

# Initialize BlockKit
bk = BlockKit()

# Construct Layout
layout = bk[
    bk.header('Hello'),
    bk.divider(),
    bk.section(
        'Hello',
        accessory=bk.button('🟣 Click me', action_id='action-id', callback=greet),
    ),
    bk.divider(),
]

# Print Layout as JSON with `{"blocks": ...}`
print(layout.to_json())

# For API Consumption
print(layout.to_api())

Note

If running directly from terminal, you will need to run uv sync or uv run <file_name>.py to install the dependencies.

Examples

See examples for more.

Supported Components

soon.

About

A concise, and opinionated, syntax for building Slack Block Kit UIs...and other things.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages