variant_picker
One choice out of a set that differs by size, colour or capacity.
The thing is chosen; the variant is not. variant_picker asks which size, which colour, which capacity, and nothing else.
It exists because asking in prose wastes a turn. "What size do you wear?" costs a round trip and a typed reply; a row of chips costs one tap, and Rendel already knows which sizes exist.
Drawn live in your browser with the SDK’s own sizes and colours, not a screenshot.
Rendered natively by the Flutter SDK and the Web SDK, both since 0.1.0.
When not to use it
Do not use it for a choice between different things, which is a choice or product_cards: a picker means the options differ by one attribute and nothing else.
Do not use it for a time, which is datetime_slots, and do not use it for several fields at once, which is form.
Props
Every block also carries type and a required fallback_text of 1 to 300 characters.
| Prop | Type | Required | Constraints |
|---|---|---|---|
title | string | No | Up to 120 characters. |
label | string | No | Up to 60 characters. What is being chosen, e.g. "Size". |
options | array | Yes | 2 to 24 entries. |
options[].id | string | Yes | 1 to 64 characters. Sent back as the user's choice when the option is tapped. |
options[].label | string | Yes | 1 to 24 characters. |
options[].available | boolean | No | false draws it faint and unselectable, still on screen. Absent means available. |
options[].swatch_hex | string | No | Matches ^#[0-9a-fA-F]{6}$. |
options[].image_url | string | No | https only. |
selected_id | string | No | Up to 64 characters. Matches an options[].id. |
style | chips | swatches | images | No | None |
On the wire
{
"id": "blk_22",
"type": "variant_picker",
"fallback_text": "Sizes 41 to 44, size 43 selected, 44 sold out.",
"props": {
"label": "Size",
"selected_id": "43",
"options": [
{ "id": "41", "label": "41" },
{ "id": "42", "label": "42" },
{ "id": "43", "label": "43" },
{ "id": "44", "label": "44", "available": false }
]
}
}Interaction
Tapping an available option sends the pick as the user's next turn: a selection of { block_id, ids: [option id] } instead of a message. The server checks it against this block. An id the block does not offer, an option shown unavailable, a block that has since been replaced, or one already answered is refused with invalid_request. The option is marked as chosen once the selection has gone out, and the question written over the page says what was picked ("Size: 43"). An option with available: false has no handler, so it dims and does not respond to a press.
style: swatches draws colour circles from each option's swatch_hex (#RRGGBB); style: images draws a thumbnail from each option's image_url (Flutter 0.44.0, Web 0.21.0).
States
| State | What the SDK draws |
|---|---|
| Loading | Chips at their real height, so the row does not reflow on hydrate. |
| Selected | The accent fills the chosen chip; its label flips to the on-accent ink. |
| Sold out | Faint ink on a decorative hairline rather than the control boundary, not pressable, still on screen. |
| Empty | Fewer than two options fails validation and degrades to fallback_text. |
Accessibility
Chips are 44pt tall and spaced, so neighbouring sizes are not one mis-tap apart. Selection is announced, not only filled, and a sold-out option announces that it is unavailable before its label, so a reader knows not to bother with the rest of the sentence.
Keep sold-out options in the list. A reader who cannot find their size learns more from a chip they can see is gone than from a list that quietly omits it.