SelectionInput

Stay organized with collections Save and categorize content based on your preferences.

The SelectionInput widget provides a set of selectable items, like a list of check boxes, radio buttons, switches, or a dropdown menu.

The widget supports suggestions, which help users enter uniform data, and on-change actions, which are Actions that run when a change occurs in the text input field, like a user adding or deleting text.

When you need to collect defined and standardized data from users, use this SelectionInput widget. To collect defined data from users, use the TextInput widget instead.

Chat apps receive and can process the value of selected items during form input events. For details about working with form inputs, see Receive form data.

Only supported in dialogs. Support for card messages coming soon.

Example

The following image displays a card consisting of a SelectionInput widget.

A dialog featuring a selection input widget.
Figure 1: A dialog asks the user to specify whether a contact is professional or personal with a SelectionInput widget.

Here's the card's JSON:

JSON

{
  "cardsV2": [
    {
      "cardId": "exampleCard",
      "card": {
        "sections": [
          {
            "header": "Add new contact",
            "widgets": [
              {
                "textInput": {
                  "label": "Notes",
                  "type": "MULTIPLE_LINE",
                  "name": "notes"
                }
              },
              {
                "selectionInput": {
                  "type": "RADIO_BUTTON",
                  "label": "Contact type",
                  "name": "contactType",
                  "items": [
                    {
                      "text": "Work",
                      "value": "Work",
                      "selected": false
                    },
                    {
                      "text": "Personal",
                      "value": "Personal",
                      "selected": false
                    }
                  ]
                }
              },
              {
                "buttonList": {
                  "buttons": [
                    {
                      "text": "Submit",
                      "onClick": {
                        "action": {
                          "function": "confirmDialogSuccess",
                          "parameters": [
                            {
                              "key": "confirmDialogSuccess",
                              "value": "confirmDialogSuccess"
                            }
                          ]
                        }
                      }
                    }
                  ]
                },
                "horizontalAlignment": "END"
              }
            ]
          }
        ]
      }
    }
  ]
}

SelectionInput JSON representation and fields

JSON representation
{
  "name": string,
  "label": string,
  "type": enum (SelectionType),
  "items": [
    {
      object (SelectionItem)
    }
  ],
  "onChangeAction": {
    object (Action)
  }
}
Fields
name

string

The name by which the selection input is identified in a form input event.

For details about working with form inputs, see Receive form data .

label

string

The text that appears above the selection input field in the user interface.

Specify text that helps the user enter the information your app needs. For example, if users are selecting the urgency of a work ticket from a drop-down menu, the label might be "Urgency" or "Select urgency".

type

enum ( SelectionType )

The way that an option appears to users. Different options support different types of interactions. For example, users can enable multiple check boxes, but can only select one value from a dropdown menu.

Each selection input supports one type of selection. Mixing check boxes and switches, for example, is not supported.

items[]

object ( SelectionItem )

An array of the selected items. For example, all the selected check boxes.

onChangeAction

object ( Action )

If specified, the form is submitted when the selection changes. If not specified, you must specify a separate button that submits the form.

For details about working with form inputs, see Receive form data .

SelectionType enumerated values

Enums
CHECK_BOX

A set of checkboxes. Users can select multiple check boxes per selection input.

Currently supported in dialogs . Support for card messages is coming soon.

RADIO_BUTTON

A set of radio buttons. Users can select one radio button per selection input.

Currently supported in dialogs . Support for card messages is coming soon.

SWITCH

A set of switches. Users can turn on multiple switches at once per selection input.

Currently supported in dialogs . Support for card messages is coming soon.

DROPDOWN

A dropdown menu. Users can select one dropdown menu item per selection input.

Currently supported in dialogs . Support for card messages is coming soon.

SelectionItem JSON representation and fields

JSON representation
{
  "text": string,
  "value": string,
  "selected": boolean
}
Fields
text

string

The text displayed to users.

value

string

The value associated with this item. The client should use this as a form input value.

For details about working with form inputs, see Receive form data .

selected

boolean

When true , more than one item is selected. If more than one item is selected for radio buttons and dropdown menus, the first selected item is received and the ones after are ignored.