Blocks are the components you will use to create the UI layout in surfaces. Within some of these blocks, you can add block elements and objects. The available blocks are:
section
divider
image
actions
context
input
preview
We will now look at the JSON payload and more details to define each of these blocks in your apps.
section
A section
is used to display text and can contain additional block elements.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
| Object{} | No | An array of text elements that should contain the following:
|
| Array[{}] | No | An array of text elements that should contain the following:
|
| Object{} | No | A section can contain the following block elements:
|
Example of a section
block
section
blockThe following section
block example contains a text object
{
type: 'section',
blockId: 'section_1',
text: {
type: 'plain_text',
text: 'lorem ipsum 🚀',
emoji: true,
},
fields: [{
type: 'plain_text',
text: 'field section'
},
{
type: 'plain_text',
text: 'field section'
}
],
accessory: { /* define any of the block elements in this object */ }
}
The UI looks something like this:
With the fields
array:
divider
A divider is a horizontal line used to visually separate different pieces of content.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
Example of a divider
block
divider
blockThe following example shows the divider
block:
{
type: 'divider',
blockId: 'divider_1',
}
On a message surface, the divider looks like this:
image
Add images to make your app more appealing.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
| String | Yes | The URL of the image. |
| String | Yes | A text describing the image being displayed. |
| Object{} | No | The text is displayed as the image's title. The object should contain the following fields:
|
Example of an image
block
image
blockThe following example shows an image
block with a title and alternate text.
{
type: 'image',
blockId: 'image_1',
imageUrl: 'https://picsum.photos/200/300',
altText: 'An image',
title: {
type: 'plain_text',
text: 'lorem ipsum 🚀',
emoji: true,
}
}
actions
An actions
block contains interactive elements and can be used to provide options.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
| Array[{}] | Yes | A list of interactive block elements. The available options are:
|
Example of an actions
block
actions
blockThe following example shows an actions
block containing a static_select
block element.
{
type: 'actions',
blockId: 'actions_1',
elements: [
{
type: 'static_select',
appId: appId,
blockId: 'static_select_action_block',
actionId: 'static_select_action_1',
placeholder: {
type: 'plain_text',
text: 'Select an option'
},
options: [
{
value: 'option_1',
text: {
type: 'plain_text',
text: 'This is your first option'
}},
{
value: 'option_2',
text: {
type: 'plain_text',
text: 'This is your second option'
}}
]}
]
}
context
You can use the context
block to provide quick information or notifications to your users.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
| Array[{}] | Yes | A list of block elements. Allowed elements are |
Example of a context
block
context
blockThe following example shows a context
block with text and image elements.
{
type: 'context',
blockId: 'context_1',
elements: [
{
type: 'plain_text',
text: 'This is a context block'
},
{
type: 'image',
imageUrl: 'https://img.freepik.com/free-vector/rocket-background-flat-style_23-2147904992.jpg?size=338&ext=jpg&ga=GA1.1.2008272138.1726444800&semt=ais_hybrid',
altText: 'An icon of a rocket'
}]
}
input
Similar to the actions
block, an input
block can contain elements to provide options and get information from users.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, |
| Object{} | Yes | A list of interactive block elements. The available options are:
|
| Object{} | Yes | The label for the block. The object should contain the following fields:
|
Example of an input
block
input
blockThe following example shows an input
block with the plain_text_input
element:
{
type: 'input',
label: {
type: 'plain_text',
text: 'Plain text input'
},
element: {
type: 'plain_text_input',
appId: appId,
actionId: 'plain_text_input_action_1',
blockId: 'plain_text_input_block_1',
placeholder: {
type: 'plain_text',
text: 'Enter the text input here'
},
}},
preview
Previews can be used to share notices or a block of information with users.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | A unique identifier for the block. |
| String | Yes | The type of the block, in this case, the value is |
| Array[{}] | Yes | The preview description object should contain the following fields:
|
| Array[{}] | Yes | The preview title object should contain the following fields:
|
Example of a preview
block
preview
blockThe following example shows a preview
block:
{
type: 'preview',
description: [
{
type: 'plain_text',
text: 'Description of preview'
}],
title: [
{
type: 'plain_text',
text: 'Title of preview'
}
]}
callout
A callout
block can be used to bring attention to specific information.
Supported surfaces: Contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | See Parameter details. |
| String | Yes | The type of the block, in this case, the value is |
| Object{} | Yes | The text object should contain the following fields:
|
| Object{} | No | The callout title object should contain the following fields:
|
| String | No | The callout style that will be displayed. The options are:
|
Example of a callout
block
callout
blockThe following example shows the callout types in a contextual bar:
{
type: 'callout',
text: {
type: 'plain_text',
text: 'Text of callout'
},
title: {
type: 'plain_text',
text: 'Title of callout'
},
variant: 'info'
},
{
type: 'callout',
text: {
type: 'plain_text',
text: 'Text of callout'
},
title: {
type: 'plain_text',
text: 'Title of callout'
},
variant: 'danger'
},
{
type: 'callout',
text: {
type: 'plain_text',
text: 'Text of callout'
},
title: {
type: 'plain_text',
text: 'Title of callout'
},
variant: 'success'
},
{
type: 'callout',
text: {
type: 'plain_text',
text: 'Text of callout'
},
title: {
type: 'plain_text',
text: 'Title of callout'
},
variant: 'warning'
}
tab navigation
Supported surfaces: Contextual bars
Field | Type | Required? | Description |
---|---|---|---|
| String | Yes | See Parameter details. |
| String | Yes | The type of the block, in this case, the value is |
| Object{} | Yes | The tab title object should contain the following fields:
|
Example of a tab_navigation
block
tab_navigation
blockThe following example shows two tabs:
{
type: 'tab_navigation',
tabs: [
{
type: 'tab',
appId: appId,
blockId: 'tab_block_1',
actionId: 'tab_action_1',
title: {
type: 'plain_text',
text: 'Tab Title'
},
},
{
type: 'tab',
appId: appId,
blockId: 'tab_block_2',
actionId: 'tab_action_2',
title: {
type: 'plain_text',
text: 'Tab Title'
},
}
]
}
conditional block
A conditional block is used to specify where the blocks can be rendered. It works with the Livechat client and in the Rocket.Chat client.
Supported surfaces: Messages, contextual bars, modals
Field | Type | Required? | Description |
---|---|---|---|
| String | No | See Parameter details. |
| String | Yes | The type of the block, in this case, the value is |
| Array[{}] | Yes | This array contains the blocks that will be displayed. The options are:
|
| Array[] | No | Determine where the blocks will be displayed. The options are |
Example of a conditional
block
conditional
blockThe following example shows the block in a message surface:
{
type: 'conditional',
render: [
{
type: 'section',
text: {
type: 'plain_text',
text: 'Conditional block'
}
}
],
when: {
engine: ['rocket.chat', 'livechat']
}
}
For more examples on using these blocks, see Using UIKit Blocks.
See the Parameter details section to learn more about the common identifiers that you may need to provide.