composition_object¶
Composition objects can be used inside of block elements and certain message payload fields. They are simply common JSON object patterns that you’ll encounter frequently when building blocks or composing messages.
The guide to Block Kit in app surfaces shows you where you can use blocks.
You can see the full Slack documentation on composition objects to see examples and the most up-to-date styling information.
TextObject¶
-
class
slack_blockkit.composition_object.
TextObject
(btype: str, text: str, emoji: bool = False, verbatim: bool = False)¶ An object containing some text, formatted either as plain_text or using mrkdwn, our proprietary textual markup that’s just different enough from Markdown to frustrate you. https://api.slack.com/reference/block-kit/composition-objects#text
- Parameters
btype (str) – The text for the block. This field accepts any of the standard text formatting markup when
btype
is mrkdwn.text (str) – The text for the block. This field accepts any of the standard text formatting markup when
btype
is mrkdwn.emoji (bool) – Indicates whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is
plain_text
.verbatim (bool) – When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed. Using a value of
True
will skip any preprocessing of this nature, although you can still include manual parsing strings. This field is only usable whenbtype
is mrkdwn.
PlainTextObject¶
-
class
slack_blockkit.composition_object.
PlainTextObject
(text: str, emoji: bool = False)¶ Represents a plain-text object. This is a
TextObject
wherebtype
is set to plain_text.- Parameters
text (str) – The text for the block. This field accepts any of the standard text formatting markup when
btype
is mrkdwn.emoji (bool) – Indicates whether emojis in a text field should be escaped into the colon emoji format.
MarkdownTextObject¶
-
class
slack_blockkit.composition_object.
MarkdownTextObject
(text: str, emoji: bool = False, verbatim: bool = False)¶ Represents a markdown text object. This is a
TextObject
wherebtype
is set to mrkdwn.- Parameters
text (str) – The text for the block. This field accepts any of the standard text formatting markup when
btype
is mrkdwn.verbatim (bool) – When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed. Using a value of
True
will skip any preprocessing of this nature, although you can still include manual parsing strings.
ConfirmObject¶
-
class
slack_blockkit.composition_object.
ConfirmObject
(title: slack_blockkit.composition_object.TextObject, text: slack_blockkit.composition_object.TextObject, confirm: slack_blockkit.composition_object.TextObject, deny: slack_blockkit.composition_object.TextObject, style: str = 'primary')¶ An object that defines a dialog that provides a confirmation step to any interactive element. This dialog will ask the user to confirm their action by offering a confirm and deny buttons. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#confirm
- Parameters
title (TextObject) – A
plain_text
-onlyTextObject
that defines the dialog’s title. Maximum length for this field is 100 characters.text (TextObject) – A
TextObject
that defines the explanatory text that appears in the confirm dialog. Maximum length for the text in this field is 300 characters.confirm (TextObject) – A
plain_text
-onlyTextObject
to define the text of the button that confirms the action. Maximum length for the text in this field is 30 characters.deny (TextObject) – A
plain_text
-onlyTextObject
to define the text of the button that cancels the action. Maximum length for the text in this field is 30 characters.style (str) – Defines the color scheme applied to the confirm button. A value of
danger
will display the button with a red background on desktop, or red text on mobile. A value ofprimary
will display the button with a green background on desktop, or blue text on mobile. If this field is not provided, the default value will beprimary
.
OptionObject¶
-
class
slack_blockkit.composition_object.
OptionObject
(text: slack_blockkit.composition_object.TextObject, value: str, description: slack_blockkit.composition_object.TextObject = None, url: str = None)¶ An object that represents a single selectable item in a select menu, multi-select menu, radio button group, or overflow menu. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#option
- Parameters
text (TextObject) – A
TextObject
that defines the text shown in the option on the menu. Overflow, select, and multi-select menus can only useplain_text
objects, while radio buttons and checkboxes can usemrkdwn
text objects. Maximum length for the text in this field is 75 characters.value (str) – The string value that will be passed to your app when this option is chosen. Maximum length for this field is 75 characters.
description (TextObject) – Optional; A
plain_text
onlyTextObject
that defines a line of descriptive text shown below the text field beside the radio button. Maximum length for the text object within this field is 75 characters.url (str) – A URL to load in the user’s browser when the option is clicked. The
url
attribute is only available in overflow menus. Maximum length for this field is 3000 characters. If you’re usingurl
, you’ll still receive an interaction payload and will need to send an acknowledgement response.
OptionGroupObject¶
-
class
slack_blockkit.composition_object.
OptionGroupObject
(label: slack_blockkit.composition_object.TextObject, options: List[slack_blockkit.composition_object.OptionObject])¶ Provides a way to group options in a select menu or multi-select menu. For more information, see: https://api.slack.com/reference/block-kit/composition-objects#option_group
- Parameters
label (TextObject) – A
plain_text
onlyTextObject
that defines the label shown above this group of options. Maximum length for the text in this field is 75 characters.options (List[OptionObject]) – An array of
OptionObject
that belong to this specific group. Maximum of 100 items.