Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
296 lines (234 loc) · 12.3 KB

File metadata and controls

296 lines (234 loc) · 12.3 KB

Building Blocks

Here is the list of objects, block elements, and blocks you can use to create interactions for your apps.

Objects

Text object

FieldTypeRequired?Description
typeStringYesThe type of text object that you want to add. The available values are plain_text and mrkdwn.
textStringYesThe actual text.
emojiBooleanNoWorks with the plain_text type.

Example

{
  type: 'plain_text',
  text: 'lorem ipsum 🚀',
  emoji: true,
}

Option object

FieldTypeRequired?Description
textObjectYesThe text that is to be displayed on the menu. The value can either be plain_text or mrkdwn.
valueStringYesThe actual value that the option represents.

Example

{
  value: 'option_1',
  text: {
      type: 'plain_text',
      text: 'lorem ipsum 🚀',
      emoji: true,
    }
}

Block elements

button

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case,button.
textObjectYesThe text that is to be displayed on the menu. The value can either be plain_text or mrkdwn.
valueStringNoA value sent along with the button information when an action is made upon the element.
urlStringNoA URL that the button points to.
styleStringNoThe style of the button. The value can either be primary or danger.
actionIdStringYesA unique identifier for an action made upon the element.

Example

{
  type: 'button',
  text: {
      type: 'plain_text',
      text: 'danger❗',
      emoji: true,
    },
  actionId: 'button_1_danger',
  style: 'danger',
}

image

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case, image.
imageUrlStringYesThe URL of the image.
altTextStringYesThe text describing the image being displayed.

Example

{
  type: 'image',
  imageUrl: 'https://picsum.photos/200/300',
  altText: 'An image',
}

overflow menu

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case, overflow.
optionsArrayYesAn array with the possible options (the options object).
actionIdStringYesA unique identifier for an action made upon the element.

Example

{
  type: 'overflow',
  actionId: 'overflow_1',
  options: [
    {
      value: 'option_1',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
    {
      value: 'option_2',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
  ],
}

plain text input

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case, plain_text_input.
actionIdStringYesA unique identifier for an action made upon the element.
placeholderObjectYesA placeholder text for the input (plain text object).
initialValueStringNoThe initial value of the field.
multilineBooleanNoA flag that indicates whether the field should be a single line (default) or a larger text area.

Example

{
  type: 'plain_text_input',
  actionId: 'plain_text_input_1',
  placeholder: {
      type: 'plain_text',
      text: 'Enter name',
      emoji: true,
    },
  initialValue: 'John Doe',
  multiline: false,
}

static select menu

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case, static_select.
actionIdStringYesA unique identifier for an action made upon the element.
placeholderObjectYesA placeholder text for the input (plain text object).
initialValueStringNoThe initial value selected (value field from the options object).
optionsArrayYesAn array with the possible options (the options object).

Example

{
  type: 'static_select',
  actionId: 'overflow_1',
  initialValue: 'option_2',
  options: [
    {
      value: 'option_1',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
    {
      value: 'option_2',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
  ],
  placeholder: {
      type: 'plain_text',
      text: 'Select an item',
    },
}

multi-static select menu

FieldTypeRequired?Description
typeStringYesThe type of the block element, in this case, multi_static_select.
actionIdStringYesA unique identifier for an action made upon the element.
placeholderObjectYesA placeholder text for the input (plain text object).
initialValueArray of stringsNoThe initial values selected (value field from the options object).
optionsArrayYesAn array with the possible options (the options object).

Example

{
  type: 'multi_static_select',
  actionId: 'overflow_1',
  initialValue: ['option_1' ,'option_2'],
  options: [
    {
      value: 'option_1',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
    {
      value: 'option_2',
      text: {
          type: 'plain_text',
          text: 'lorem ipsum 🚀',
          emoji: true,
        }
    },
  ],
  placeholder: {
      type: 'plain_text',
      text: 'Select an item',
    },
}

Blocks

section

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, section.
textObjectYesThe text that is to be displayed on the button. The value can either be plain_text or mrkdwn.
accessoryObjectNoOne element that can be a button element, an image element, or an overflow menu.

Example

{
  type: 'section',
  blockId: 'section_1',
  text: {
      type: 'plain_text',
      text: 'lorem ipsum 🚀',
      emoji: true,
    }
  accessory: { /* one of the accessory elements */ } ,
}

{% hint style="info" %} Notice how the section block and the button element are used in the Contextual Bar app. {% endhint %}

divider

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, divider.

Example

{
  type: 'divider',
  blockId: 'divider_1',
}

image

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, image.
imageUrlStringYesThe URL of the image.
altTextStringYesA text describing the image being displayed.
titleObjectNoThe text to be displayed as the image's title. The value can either be plain_text or mrkdwn.

Example

{
  type: 'image',
  blockId: 'image_1',
  imageUrl: 'https://picsum.photos/200/300',
  altText: 'An image',
  title: {
      type: 'plain_text',
      text: 'lorem ipsum 🚀',
      emoji: true,
    }
}

actions

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, actions.
elementsArrayYesA list of interactive block elements.

Example

{
  type: 'actions',
  blockId: 'actions_1',
  elements: [ /* block elements */ ]
}

context

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, context.
elementsArrayYesA list of block elements. Allowed elements are plain text object and image element.

Example

{
  type: 'context',
  blockId: 'context_1',
  elements: [ /* block elements */ ]
}

input

FieldTypeRequired?Description
blockIdStringNoA unique identifier for the block.
typeStringYesThe type of the block, in this case, input.
elementArrayYesThe input element, that can be plain text input, static select menu, and multi static select menu.

Example

{
  type: 'input',
  blockId: 'input_1',
  element: { /* input element */ }
}

Now that we've seen the different building blocks that can be used for our apps, let's take a look at how to use action buttons to initiate a set of actions in the next section.