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)
| Parameter | Description |
|---|---|
values | sections 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
| Throws | When |
|---|---|
ValidationException | if 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)
| Parameter | Description |
|---|---|
title | plain-text heading |
Returns: a new builder
Related types: AccordionSection
Blocks
Appends blocks revealed when this section is expanded.
public AccordionSection.Builder blocks(Block... values)
| Parameter | Description |
|---|---|
values | blocks in display order |
Returns: this builder
Related types: AccordionSection, Block
Subtitle — String
Sets supporting Slack Markdown copy.
public AccordionSection.Builder subtitle(String value)
| Parameter | Description |
|---|---|
value | Markdown text |
Returns: this builder
Related types: AccordionSection
Subtitle — Text
Sets a typed supporting text value.
public AccordionSection.Builder subtitle(Text value)
| Parameter | Description |
|---|---|
value | Slack text object |
Returns: this builder
Related types: AccordionSection, Text
Icon
Sets the section header icon.
public AccordionSection.Builder icon(ImageElement value)
| Parameter | Description |
|---|---|
value | image element |
Returns: this builder
Related types: AccordionSection, ImageElement
Expanded
Controls whether the section starts expanded.
public AccordionSection.Builder expanded(boolean value)
| Parameter | Description |
|---|---|
value | initial expanded state |
Returns: this builder
Related types: AccordionSection
Width
Sets the Slack-native container width.
public AccordionSection.Builder width(ContainerWidth value)
| Parameter | Description |
|---|---|
value | container width |
Returns: this builder
Related types: AccordionSection, ContainerWidth
HasHeaderDivider
Controls the divider below the section header.
public AccordionSection.Builder hasHeaderDivider(boolean value)
| Parameter | Description |
|---|---|
value | whether to show the divider |
Returns: this builder
Related types: AccordionSection
BlockId
Sets a deterministic block identifier.
public AccordionSection.Builder blockId(String value)
| Parameter | Description |
|---|---|
value | block 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
| Throws | When |
|---|---|
ValidationException | if 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)
| Parameter | Description |
|---|---|
actionIdPrefix | prefix 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)
| Parameter | Description |
|---|---|
values | source blocks |
Returns: this builder
Related types: Block, Paginator
Page
Selects the one-based page to render.
public Paginator.Builder page(int value)
| Parameter | Description |
|---|---|
value | one-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)
| Parameter | Description |
|---|---|
value | positive page size |
Returns: this builder
Related types: Paginator
PreviousText
Sets the previous-page button label.
public Paginator.Builder previousText(String value)
| Parameter | Description |
|---|---|
value | button label |
Returns: this builder
Related types: Paginator
NextText
Sets the next-page button label.
public Paginator.Builder nextText(String value)
| Parameter | Description |
|---|---|
value | button 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)
| Parameter | Description |
|---|---|
value | whether 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)
| Parameter | Description |
|---|---|
value | block 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
| Throws | When |
|---|---|
ValidationException | if there are no blocks, the prefix is empty, or the page or page size is out of range |
Related types: Block