actions_block: Actions Block

View source: R/layout.R

actions_blockR Documentation

Actions Block

Description

A block that is used to hold interactive elements.

Usage

actions_block(elements, id = NULL)

Arguments

elements

An array of interactive element objects: buttons, select menus, overflow menus, or date pickers. There is a maximum of 5 elements in each action block.

id

character, A string acting as a unique identifier for a block. Default: NULL

Details

Available in surfaces: Modals, Messages, Home tabs

Value

actions_block class

See Also

Other layout: as.blocks(), context_block(), divider_block(), file_block(), image_block(), input_block(), section_block(), wrap_blocks()

Examples


# An actions block with a select menu and a button:

actions_block(
  id = 'actions1',
  elements = wrap_blocks(
    select_menu(
      placeholder = 'Which witch is the witchiest witch?',
      id = 'select_2',
      options = as.blocks(
        lapply(c('Matilda','Glinda','Granny Weatherwax','Hermione'),
        FUN = function(x){
          block_option(
            text = x, 
            value = gsub('\\s','',tolower(x))
           )
        })
     )
    ),
    button_element(
      text = 'Cancel',
      value = 'cancel',
      id = 'button_1'
    )
 )
)

# An actions block with a datepicker, an overflow, and a button:

actions_block(
  id = 'actionblock789',
  elements = wrap_blocks(
    datepicker_element(
      id = 'datepicker123',
      initial_date = '1990-04-28',
      placeholder = 'Select a date'
    ),
    overflow_menu(
      id = 'overflow',
      options = as.blocks(
        lapply(sprintf('value-%d',1:4),block_option,
        text = '*this is plain_text text*')
       )
    ),
    button_element(
      text = 'Click Me',
      value = 'click_me_123',
      id = 'button'
    )
  )
)


yonicd/slackblocks documentation built on March 2, 2023, 6:53 a.m.