Guide / Controls / Layout

Sections

Headings that open and close

When to use it. A vertical stack of collapsible sections. Each section is a group whose label is the header and whose grid of children is the expandable body. In single mode the open section index is the control value (so it syncs and fires actions); in multi mode sections open independently.

Type
accordion
Also titled
Accordion
Default size
3 rows × 2 columns
Symbol
list.bullet.below.rectangle
Docs
Docs complete
Search for it as
  • collapse
  • expand
  • section
  • fold
  • disclosure
  • faq
Sections: Single-open settings, synced
Rendered by the app

Fields

6 fields you can set on a accordion control. Every control also takes the shared fields (id, position, span, sync, action).

Fields
FieldTypeDefaultWhat it does
Open modeaccordionModechoiceone of 2single

Whether opening one section closes the others

Single keeps one section open at a time; multi lets any number stay open together.

  • single defaultopening a section closes the one that was open
  • multievery section opens and closes on its own
expandedIndexexpandedIndexnumber0

Which section is open when the layout appears

Opens the section at this position on load, counting from 0; -1 starts with every section closed.

ChevronshowChevronon / offtrue (on)

The small arrow beside each heading

Shows or hides the arrow at the end of each heading; hidden leaves just the heading text.

panelspanelsobject—

The headings and the content under each

Each entry becomes one heading row that expands to show its own controls.

containerAnimationcontainerAnimationobject—

How the sections animate when opening or closing

Tunes the spring and speed of expanding and collapsing, e.g. profile smooth or duration 0.3 seconds.

defaultValuedefaultValuenumberstep 1—

The section that starts open

Opens the section at this position on load (from 0) and wins over the open-on-load index; -1 starts all closed.

Theme fields

Restyle one control by setting these in its theme object; a layout's theme sets them for every control.

Theme fields
FieldTypeDefaultWhat it does
surfacePrimarytheme.surfacePrimarycolor#FFFFFF0F

The fill behind each section card

Paints every section card in this color, including its transparency.

accentColortheme.accentColorcolor#667eea

The color of the arrows

Tints the chevron on every heading in this color.

Frosted glasstheme.blurEnabledon / offtrue (on)

How heavy the outline is

Sets the outline thickness from 0 (none) to 5 points.

Card spacingtheme.cardPaddingnumber0–32 ptstep 112

Breathing room inside each section

Adds 0 to 32 points between a section card edge and its content.

Corner roundnesstheme.cornerRadiusnumber0–30 ptstep 112

The color of the heading words

Paints the section headings and default text in this color.

Emits and receives

What this control sends when you use it, and what it can show or follow when data arrives.

Emits

Emits
SendsWhenTypeWhat it sends
When you open or close a sectionvaluetapnumber

the position of the section you opened, counting from 0 (-1 when you collapse it)

In multi mode sections open independently and the value is only the last one you toggled

Example: 1

Receives

Receives
TakesFromTypeWhat it does
valuefollowhub, mqtt, http, store, defaultnumber

the position of the section to open, counting from 0 (-1 closes all)

that section opens (in single mode, stepping through the sections in between); multi mode keeps its own open set

Example: 1

Examples

4 examples, each one a control you can paste into a layout.

Single-open settings, synced

Shows single mode with a spring animation: only one section stays open and the open index is the control value. Intended effect: tapping Network closes Display and opens Network.

JSON 15 lines
{
  "type": "accordion",
  "id": "settings",
  "position": [0, 0],
  "span": [4, 2],
  "accordionMode": "single",
  "expandedIndex": 0,
  "containerAnimation": { "profile": "smooth", "chevronRotation": 90 },
  "panels": [
    { "type": "group", "id": "display", "label": "Display", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "slider", "id": "bright", "position": [0,0], "label": "Brightness", "min": 0, "max": 100 } ] },
    { "type": "group", "id": "network", "label": "Network", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "toggle", "id": "wifi", "position": [0,0], "label": "Wi-Fi" } ] }
  ]
}

Open in CAR-TER

Sections: Single-open settings, synced
Rendered by the app

Multi-open FAQ

Shows multi mode, no chevron and all sections starting closed. Intended effect: each question opens on its own and several answers can stay open at once, with plain headings.

JSON 15 lines
{
  "type": "accordion",
  "id": "faq",
  "position": [0, 0],
  "span": [4, 3],
  "accordionMode": "multi",
  "expandedIndex": -1,
  "showChevron": false,
  "panels": [
    { "type": "group", "id": "q1", "label": "How do I reset it?", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "label", "id": "a1", "position": [0,0], "text": "Hold the button for five seconds." } ] },
    { "type": "group", "id": "q2", "label": "Where is the log?", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "label", "id": "a2", "position": [0,0], "text": "Open the Logs page." } ] }
  ]
}

Open in CAR-TER

Sections: Multi-open FAQ
Rendered by the app

Action and sync on the open section

Shows the action fired on every toggle and a sync that opens a section from the server. Intended effect: tapping a heading sends its index (-1 when collapsing) and a broadcast scene message opens the matching section on the phone.

JSON 17 lines
{
  "type": "accordion",
  "id": "scenes",
  "position": [0, 0],
  "span": [4, 2],
  "accordionMode": "single",
  "defaultValue": 0,
  "containerAnimation": { "profile": "bouncy", "multiStep": true, "stepInterval": 0.12 },
  "sync": [{ "method": "meshsocket", "type": "listen", "event": "broadcast", "filter": { "msg_type": "scene" }, "valuePath": "index" }],
  "action": { "method": "meshsocket", "mode": "send", "event": "route_msg_noreply", "payload": { "target_name": "hub", "type": "scene", "payload": { "index": "{{value}}" } } },
  "panels": [
    { "type": "group", "id": "home", "label": "Home", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "label", "id": "home-l", "position": [0,0], "text": "Home scene" } ] },
    { "type": "group", "id": "away", "label": "Away", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "label", "id": "away-l", "position": [0,0], "text": "Away scene" } ] }
  ]
}

Open in CAR-TER

Sections: Action and sync on the open section
Rendered by the app

Themed frosted cards

Shows the theme fields: frosted glass, a thick border and larger spacing. Intended effect: roomy, rounded section cards with a visible outline.

JSON 14 lines
{
  "type": "accordion",
  "id": "themed",
  "position": [0, 0],
  "span": [4, 2],
  "blurEnabled": true,
  "borderWidth": 2,
  "cardPadding": 20,
  "cornerRadius": 24,
  "panels": [
    { "type": "group", "id": "t1", "label": "Details", "position": [0,0], "grid": { "columns": 1, "rows": 1 },
      "children": [ { "type": "label", "id": "t1l", "position": [0,0], "text": "More here" } ] }
  ]
}

Open in CAR-TER

Note: expandedIndex and defaultValue do the same job; use only one.

Sections: Themed frosted cards
Rendered by the app

Try it on your phone

carterkit serves a small hub on your computer and pushes one example to CAR-TER on your iPhone or iPad. Pair once with the code it prints.

  1. Install the Python kit.

    pip install carterkit
  2. Show “Single-open settings, synced” on your phone.

    carterkit demo accordion --example 'Single-open settings, synced'
  3. Swap in any example name from this page, or leave --example off for the first one.

carterkit quickstart · Get CAR-TER

Animation Customization

Field Type Default Description
profile string bouncy Base spring profile
duration number — Override expand/collapse seconds
bounce number — Spring bounce 0–1
multiStep bool true Cascade through sections on a multi-step jump (single mode)
stepInterval number 0.12 Seconds per intermediate step
chevronRotation number 90 Chevron rotation° when expanded

Theming

Sections are glass cards from the active theme; the chevron uses accentColor.

Generated from ControlDocs/accordion.md. Something unclear or missing? Tell me.