Skip to main content

Components

This page documents the public Java API for components, generated from the Javadoc by the javadoc tool. Values are immutable, builders are concrete and fluent, validation runs when you call .build(), and typed getters read built values back.

Components expand to ordinary List<Block> values. The application remains responsible for channel selection, delivery options, and interaction handling through slack-java-sdk.

Accordion​

Assembles independently collapsible sections. Slack handles expanding and collapsing, so no interaction handler is needed. Pass the result to the Slack SDK with List.copyOf, which widens it to List<LayoutBlock>.

Builder​

Starts a concrete fluent accordion builder.

public static Accordion.Builder builder()

Returns: a new builder

Related types: Accordion

Sections​

Appends built accordion sections in display order.

public Accordion.Builder sections(ContainerBlock... values)
ParameterDescription
valuessections created with AccordionSection

Returns: this builder

Related types: Accordion, ContainerBlock

Build​

Builds ordinary Slack container blocks ready for an SDK request.

public List<Block> build()

Returns: immutable list of container blocks

ThrowsWhen
ValidationExceptionif there are no sections or a section is not collapsible

Related types: Block

AccordionSection​

Builds one independently collapsible, Slack-native accordion section.

Builder​

Starts a section with its required heading.

public static AccordionSection.Builder builder(String title)
ParameterDescription
titleplain-text heading

Returns: a new builder

Related types: AccordionSection

Blocks​

Appends blocks revealed when this section is expanded.

public AccordionSection.Builder blocks(Block... values)
ParameterDescription
valuesblocks in display order

Returns: this builder

Related types: AccordionSection, Block

Subtitle — String​

Sets supporting Slack Markdown copy.

public AccordionSection.Builder subtitle(String value)
ParameterDescription
valueMarkdown text

Returns: this builder

Related types: AccordionSection

Subtitle — Text​

Sets a typed supporting text value.

public AccordionSection.Builder subtitle(Text value)
ParameterDescription
valueSlack text object

Returns: this builder

Related types: AccordionSection, Text

Icon​

Sets the section header icon.

public AccordionSection.Builder icon(ImageElement value)
ParameterDescription
valueimage element

Returns: this builder

Related types: AccordionSection, ImageElement

Expanded​

Controls whether the section starts expanded.

public AccordionSection.Builder expanded(boolean value)
ParameterDescription
valueinitial expanded state

Returns: this builder

Related types: AccordionSection

Width​

Sets the Slack-native container width.

public AccordionSection.Builder width(ContainerWidth value)
ParameterDescription
valuecontainer width

Returns: this builder

Related types: AccordionSection, ContainerWidth

HasHeaderDivider​

Controls the divider below the section header.

public AccordionSection.Builder hasHeaderDivider(boolean value)
ParameterDescription
valuewhether to show the divider

Returns: this builder

Related types: AccordionSection

BlockId​

Sets a deterministic block identifier.

public AccordionSection.Builder blockId(String value)
ParameterDescription
valueblock identifier

Returns: this builder

Related types: AccordionSection

Build​

Builds this section as an ordinary, collapsible Slack container block.

public ContainerBlock build()

Returns: validated container block

ThrowsWhen
ValidationExceptionif the section breaks a container block rule, such as having no blocks or more than ten

Related types: ContainerBlock

Paginator​

Renders one page of blocks plus previous and next buttons.

The buttons' action IDs are <prefix>.previous and <prefix>.next, and their values hold the one-based page to show next, so an action handler can rebuild the message for that page. Pass the result to the Slack SDK with List.copyOf, which widens it to List<LayoutBlock>:

List<Block> page = Paginator.builder("results").blocks(results).page(2).build();
client.chatPostMessage(ChatPostMessageRequest.builder()
.channel("C0123456")
.text("Search results")
.blocks(List.copyOf(page))
.build());

Builder​

Starts a paginator with the prefix used for generated action identifiers.

public static Paginator.Builder builder(String actionIdPrefix)
ParameterDescription
actionIdPrefixprefix for previous and next action IDs

Returns: a new builder

Related types: Paginator

Blocks​

Appends source blocks in display order.

public Paginator.Builder blocks(Block... values)
ParameterDescription
valuessource blocks

Returns: this builder

Related types: Block, Paginator

Page​

Selects the one-based page to render.

public Paginator.Builder page(int value)
ParameterDescription
valueone-based page number

Returns: this builder

Related types: Paginator

PageSize​

Sets the number of source blocks displayed per page.

public Paginator.Builder pageSize(int value)
ParameterDescription
valuepositive page size

Returns: this builder

Related types: Paginator

PreviousText​

Sets the previous-page button label.

public Paginator.Builder previousText(String value)
ParameterDescription
valuebutton label

Returns: this builder

Related types: Paginator

NextText​

Sets the next-page button label.

public Paginator.Builder nextText(String value)
ParameterDescription
valuebutton label

Returns: this builder

Related types: Paginator

ShowPageIndicator​

Controls whether a “Page n of m” context block is rendered.

public Paginator.Builder showPageIndicator(boolean value)
ParameterDescription
valuewhether to show the indicator

Returns: this builder

Related types: Paginator

BlockId​

Sets the identifier of the generated actions block. It is not used when every block fits on one page, because no controls are rendered.

public Paginator.Builder blockId(String value)
ParameterDescription
valueblock identifier

Returns: this builder

Related types: Paginator

Build​

Builds the selected page followed, when there is more than one page, by a "Page n of m" context block and the navigation buttons.

public List<Block> build()

Returns: immutable list of ordinary blocks

ThrowsWhen
ValidationExceptionif there are no blocks, the prefix is empty, or the page or page size is out of range

Related types: Block