2018-01-03 20:14:15 -02:00
---
2018-08-14 11:33:13 -06:00
label: "List"
2018-10-01 20:00:57 -04:00
title: list
2018-01-03 20:14:15 -02:00
---
The list widget allows you to create a repeatable item in the UI which saves as a list of widget values. map a user-provided string with a comma delimiter into a list. You can choose any widget as a child of a list widget—even other lists.
- **Name:** `list`
- **UI:** if `fields` is specified, field containing a repeatable child widget, with controls for adding, deleting, and re-ordering the repeated widgets; if unspecified, a text input for entering comma-separated values
- **Data type:** list of widget values
- **Options:**
- `default` : if `fields` is specified, declare defaults on the child widgets; if not, you may specify a list of strings to populate the text field
2018-11-20 23:31:54 +02:00
- `allow_add` : if added and labeled `false` , button to add additional widgets disappears
2020-01-29 18:59:02 +01:00
- `collapsed` : if added and labeled `false` , the list widget's content does not collapse by default
2018-01-03 20:14:15 -02:00
- `field` : a single widget field to be repeated
- `fields` : a nested list of multiple widget fields to be included in each repeatable iteration
- **Example** (`field`/`fields` not specified):
2018-08-14 07:37:07 -07:00
```yaml
2018-08-14 11:33:13 -06:00
- label: "Tags"
name: "tags"
widget: "list"
default: ["news"]
2018-08-14 07:37:07 -07:00
```
2018-03-15 16:16:32 -04:00
- **Example** (`allow_add` marked `false` ):
2018-08-14 07:37:07 -07:00
```yaml
2018-08-14 11:33:13 -06:00
- label: "Tags"
name: "tags"
widget: "list"
2018-08-14 07:37:07 -07:00
allow_add: false
2018-08-14 11:33:13 -06:00
default: ["news"]
2018-08-14 07:37:07 -07:00
```
2018-01-03 20:14:15 -02:00
- **Example** (with `field` ):
2018-08-14 07:37:07 -07:00
```yaml
2018-08-14 11:33:13 -06:00
- label: "Gallery"
name: "galleryImages"
widget: "list"
2018-10-05 00:48:27 +01:00
field: {label: Image, name: image, widget: image}
2018-08-14 07:37:07 -07:00
```
2018-01-03 20:14:15 -02:00
- **Example** (with `fields` ):
2018-08-14 07:37:07 -07:00
```yaml
2018-08-14 11:33:13 -06:00
- label: "Testimonials"
name: "testimonials"
widget: "list"
2018-08-14 07:37:07 -07:00
fields:
2018-08-14 11:33:13 -06:00
- {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
2018-08-14 07:37:07 -07:00
- label: Author
name: author
widget: object
fields:
2018-08-14 11:33:13 -06:00
- {label: Name, name: name, widget: string, default: "Emmet"}
- {label: Avatar, name: avatar, widget: image, default: "/img/emmet.jpg"}
2018-08-14 07:37:07 -07:00
```
2020-01-29 18:59:02 +01:00
- **Example** (`collapsed` marked `false` ):
```yaml
- label: "Testimonials"
name: "testimonials"
collapsed: false
widget: "list"
fields:
- {label: Quote, name: quote, widget: string, default: "Everything is awesome!"}
- {label: Author, name: author, widget: string }
```