Skip to main content

Components

This page documents the public Go API for components. Every constructor and method shown here is part of the fluent github.com/nicklambourne/slackblocks/go/v2 package.

Higher-level components expose SlackBlocks() ([]slack.Block, error), expanding them into ordinary blocks ready for slack.MsgOptionBlocks.

AccordionBuilder

AccordionBuilder assembles independently collapsible sections.

type AccordionBuilder struct { /* contains filtered or unexported fields */ }

NewAccordion

NewAccordion creates a Slack-native accordion component.

func NewAccordion() *AccordionBuilder

Related types: AccordionBuilder.

NewAccordionSection

NewAccordionSection creates one Slack-native collapsible container for an accordion. Add its content with Blocks and choose its initial state with Expanded.

func NewAccordionSection() *AccordionSectionBuilder

AccordionSectionBuilder

AccordionSectionBuilder is the concrete fluent builder returned by NewAccordionSection. Use NewAccordionSection rather than constructing this type directly.

type AccordionSectionBuilder struct { /* contains filtered or unexported fields */ }

Its fluent methods return the same concrete builder, so invalid fields are rejected at compile time.

AccordionSectionBuilder.Title

Title sets a title field.

func (b *AccordionSectionBuilder) Title(value any) *AccordionSectionBuilder

AccordionSectionBuilder.Subtitle

Subtitle sets secondary heading copy.

func (b *AccordionSectionBuilder) Subtitle(value any) *AccordionSectionBuilder

AccordionSectionBuilder.Blocks

Blocks appends Block Kit blocks.

func (b *AccordionSectionBuilder) Blocks(values ...any) *AccordionSectionBuilder

AccordionSectionBuilder.Expanded

Expanded controls whether an accordion section starts open. It stores a private sentinel that the accordion-section transform converts to Slack's inverse default_collapsed field during Build.

func (b *AccordionSectionBuilder) Expanded(value bool) *AccordionSectionBuilder

AccordionSectionBuilder.BlockID

BlockID assigns an application-defined block identifier.

func (b *AccordionSectionBuilder) BlockID(value string) *AccordionSectionBuilder

Every AccordionSectionBuilder also provides Build() (Object, error), MustBuild() Object, and JSON marshaling. Set(field, value) is available as an advanced raw wire-format escape hatch; it deliberately ends the typed fluent chain.

NewPaginator

NewPaginator creates a pure Block Kit paginator. Interaction handling remains in the application; generated button values contain the next one-based page.

func NewPaginator() *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder

PaginatorBuilder renders one page of blocks plus navigation controls.

type PaginatorBuilder struct { /* contains filtered or unexported fields */ }

AccordionBuilder.BuildMany

BuildMany materialises the accordion as ordinary container blocks.

func (b *AccordionBuilder) BuildMany() ([]Object, error)

Related types: AccordionBuilder, Object.

AccordionBuilder.Sections

Sections appends accordion sections in display order.

func (b *AccordionBuilder) Sections(values ...any) *AccordionBuilder

Related types: AccordionBuilder.

AccordionBuilder.SlackBlocks

SlackBlocks expands the accordion for direct use with slack-go.

func (b *AccordionBuilder) SlackBlocks() ([]slack.Block, error)

Related types: AccordionBuilder.

PaginatorBuilder.ActionIDPrefix

ActionIDPrefix sets the prefix used for generated action IDs.

func (b *PaginatorBuilder) ActionIDPrefix(value string) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.BlockID

BlockID sets the generated actions block identifier.

func (b *PaginatorBuilder) BlockID(value string) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.Blocks

Blocks appends source blocks in display order.

func (b *PaginatorBuilder) Blocks(values ...any) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.BuildMany

BuildMany materialises the selected page and its controls.

func (b *PaginatorBuilder) BuildMany() ([]Object, error)

Related types: Object, PaginatorBuilder.

PaginatorBuilder.NextText

NextText sets the next-page button label.

func (b *PaginatorBuilder) NextText(value string) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.Page

Page selects the one-based page to render.

func (b *PaginatorBuilder) Page(value int) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.PageSize

PageSize sets the number of source blocks displayed per page.

func (b *PaginatorBuilder) PageSize(value int) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.PreviousText

PreviousText sets the previous-page button label.

func (b *PaginatorBuilder) PreviousText(value string) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.ShowPageIndicator

ShowPageIndicator controls the Page n of m context block.

func (b *PaginatorBuilder) ShowPageIndicator(value bool) *PaginatorBuilder

Related types: PaginatorBuilder.

PaginatorBuilder.SlackBlocks

SlackBlocks expands the selected page for direct use with slack-go.

func (b *PaginatorBuilder) SlackBlocks() ([]slack.Block, error)

Related types: PaginatorBuilder.