Skip to content

Components

A view builds a typed element tree. Arona serializes that tree to the platform payload. The same component model works on Slack, with a different vocabulary.

Top-level layout:

  • Container, Text, Section, Separator
  • ActionRow, Button, LinkButton
  • Select with Option, plus UserSelect, RoleSelect, MentionableSelect, ChannelSelect
  • Thumbnail, Media, Gallery, File, Canvas
  • Modal, Label, TextInput, Checkbox, CheckboxGroup, RadioGroup, FileUpload
  • Fragment, to group top-level elements without adding a container

A Section can carry one accessory:

Section(h, {
accessory: Button(h, {
onClick: Message.Clicked(),
children: ["Refresh"],
}),
children: [Text(h, "Current status: ready")],
});

Arona does not add structural components for you. A misplaced element throws a descriptive error when the message is serialized.

  • Button, LinkButton, and every select belong in an ActionRow.
  • Media and Canvas belong in a Gallery.
  • Modal fields belong in a Label.
  • A Discord Section must have an accessory.
  • A Slack Text or Markdown belongs in a Section.
  • A Slack Button belongs in Actions, or is the Section accessory.
  • A Slack Actions needs at least one Button.

Use Fragment when a view needs several top-level elements.

Select and Modal are headless components. They own ids, defaults, and validation. You draw their parts and receive a message:

ActionRow(h, {
children: [
Select(h, {
placeholder: "Pick a character",
onChange: (interaction) => Message.Changed({ id: interaction.values[0] ?? "" }),
children: characters.map((character) =>
Option(h, { value: String(character.id), label: character.name }),
),
}),
],
});

Discord puts modal fields inside labels. Arona requires the Label:

Modal(h, {
title: "Profile",
onSubmit: (payload) =>
Submitted({
name: payload.values.name ?? "",
newsletter: payload.checkboxes.newsletter ?? false,
plan: payload.radioGroups.plan ?? "",
}),
children: [
Label(h, {
label: "Name",
children: [TextInput(h, { name: "name" })],
}),
Label(h, {
label: "Newsletter",
children: [Checkbox(h, { name: "newsletter" })],
}),
Label(h, {
label: "Plan",
children: [
RadioGroup(h, {
name: "plan",
children: [
RadioOption(h, { value: "free", label: "Free" }),
RadioOption(h, { value: "pro", label: "Pro" }),
],
}),
],
}),
],
});

onSubmit receives text, select, checkbox, radio, mentionable, and file values, each keyed by the field name.

The working example is examples/simple.

Slack uses Blocks, Section, Text, Markdown, Actions, Button, and Divider. See Create a Slack bot for the app setup and the block rules.