# StringListEditor

> StringListEditor edits a list of unique strings with a list, an input field and Add and Remove buttons - server addresses, item ids, player names.

URL: https://xichil.dev/docs/xis-mvui/v1/widgets/string-list-editor/ · Updated: 2026-11-06 · Applies to: Fabric, Quilt, Legacy Fabric, Forge, NeoForge, MC 1.7.10 - 26.3

Edits a list of unique strings, such as server addresses, item ids or ignored player names: a list of the
items, a text field for a new item, and Add and Remove buttons.

```java
StringListEditor ignored = StringListEditor.builder("ignored")
        .items(() -> config.ignoredPlayers)               // re-read on every refresh
        .onAdd(name -> config.ignoredPlayers.add(name))
        .onRemove(name -> config.ignoredPlayers.remove(name))
        .inputLabel(Text.translatable("mymod.ignored.add", "Player name"))
        .validator(s -> s.contains(" ") ? Text.translatable("mymod.ignored.space", "No spaces") : null)
        .maxLength(16)
        .build();

MenuScreen.builder("main").title(title).add(ignored).build();   // or Section.Builder.add(ignored)
```

## Builder

| Method | Required | Default | Notes |
| --- | --- | --- | --- |
| `items(Supplier<List<String>>)` | yes | | the current items in display order; re-read on every refresh |
| `onAdd(Consumer<String>)` | yes | | adds an item to your list when Add is pressed; gets only non-empty, valid text that isn't in the list yet |
| `onRemove(Consumer<String>)` | yes | | removes an item from your list when Remove is pressed |
| `inputLabel(Text)` | yes | | the label above the text field, e.g. "Server address" |
| `validator(Function<String, Text>)` | no | none | an extra check for a new item; empty input and duplicates are handled already |
| `addLabel(Text)` | no | `UiTexts.ADD` ("Add") | |
| `removeLabel(Text)` | no | `UiTexts.REMOVE` ("Remove") | |
| `maxLength(int)` | no | `256` | the most characters of a new item |

It has no `enabled`, `tooltip` or `visible` of its own: it isn't a single entry.

## What it is made of

The editor expands into four ordinary entries, so every backend can draw it:

| Entry | Id | Enabled |
| --- | --- | --- |
| a [SelectList](https://xichil.dev/docs/xis-mvui/v1/widgets/select-list/index.md) of the items, as literal text | `<id>.list` | always |
| a [TextInput](https://xichil.dev/docs/xis-mvui/v1/widgets/text-input/index.md) for a new item | `<id>.input` | always |
| the Add [Button](https://xichil.dev/docs/xis-mvui/v1/widgets/button/index.md) | `<id>.add` | while the field holds non-empty, valid text not in the list ("Already in the list" otherwise) |
| the Remove [Button](https://xichil.dev/docs/xis-mvui/v1/widgets/button/index.md) | `<id>.remove` | while a row is selected |

Pressing Add passes the text to `onAdd` and empties the field. Pressing Remove passes the selected item to
`onRemove` and clears the selection. Keep the four ids free on your screen.

## Behaviour

- **Your code stores the items**: `onAdd` and `onRemove` must change what `items` returns.
- Items should be unique; each is also its row's id, and a duplicate row id turns the menu off.
- Add it with `MenuScreen.Builder.add(editor)` or `Section.Builder.add(editor)`.
- **Footer:** no.

## Test it

```java
host.type("ignored.input", "Steve").click("ignored.add");
host.select("ignored.list", "Steve").click("ignored.remove");
```

## See also

- Javadoc: [StringListEditor](https://xichil.dev/javadoc/xis-mvui/v1/dev/xichil/mvui/StringListEditor.html)
