Skip to main content

Components

This page documents the public C# API for components, generated from the XML documentation of the compiled library. Values are immutable, constructors take named arguments and validate them, and read-only properties return what was passed.

Components return ordinary IReadOnlyList<IBlock> values that spread into any block collection. The application remains responsible for delivery and interaction handling.

Accordion

A stack of independently collapsible sections, each a Slack container block.

Build the sections with AccordionSection.Create. The result is an ordinary list of blocks that can be combined with other blocks, for example blocks: [header, ..Accordion.Create(sections)].

Create

Combines accordion sections into a list of blocks.

public static IReadOnlyList<IBlock> Create(IEnumerable<ContainerBlock> sections)
ParameterDescription
sectionsSections created by AccordionSection.Create, in display order.

Returns: The sections as blocks.

ThrowsWhen
ValidationExceptionThere are no sections, or a section is not a collapsible container.

Related types: ContainerBlock, IBlock

AccordionSection

Creates one collapsible accordion section.

Create

Creates a collapsible container block for use in an Accordion.

public static ContainerBlock Create(PlainText title, IEnumerable<IBlock> blocks, Text? subtitle = null, ImageElement? icon = null, bool expanded = false, ContainerWidth width = ContainerWidth.Standard, bool hasHeaderDivider = false, string? blockId = null)
ParameterDescription
titleHeading shown whether the section is expanded or collapsed.
blocksBlocks revealed when the section is expanded.
subtitleSupporting text below the heading. A string is sent as mrkdwn.
iconImage shown beside the heading.
expandedWhether the section starts expanded.
widthContainer width.
hasHeaderDividerWhether a divider separates the heading from the content.
blockIdBlock identifier for the container.

Returns: A validated collapsible ContainerBlock.

ThrowsWhen
ValidationExceptionThe section breaks a Block Kit rule.

Related types: ContainerBlock, ContainerWidth, IBlock, ImageElement, PlainText, Text

Paginator

Selects one page of blocks and adds standard navigation controls.

The result is an ordinary list of blocks. When there is more than one page it ends with an optional Page N of M context block and an actions block holding previous and next buttons. Button action identifiers are {actionIdPrefix}.previous and {actionIdPrefix}.next, and their values carry the one-based page number to show.

Create

Builds one page of blocks with navigation.

public static IReadOnlyList<IBlock> Create(string actionIdPrefix, IEnumerable<IBlock> blocks, int page = 1, int pageSize = 5, string previousText = "Previous", string nextText = "Next", bool showPageIndicator = true, string? blockId = null)
ParameterDescription
actionIdPrefixPrefix for the navigation buttons' action identifiers.
blocksEvery block across all pages, in display order.
pageThe one-based page to show.
pageSizeHow many blocks each page shows.
previousTextLabel of the previous-page button.
nextTextLabel of the next-page button.
showPageIndicatorWhether to add a Page N of M context block.
blockIdBlock identifier for the navigation actions block.

Returns: The blocks for the requested page, followed by the navigation blocks when needed.

ThrowsWhen
ValidationExceptionThere are no blocks, the prefix is empty, or the page or page size is out of range.

Related types: IBlock