Multi-select
A multi-select keeps several answers in a single field. Use it for a growing list of labels when people need to see and remove the choices they have made.
Tag a draft
#Add Home or Travel to the draft, then remove a label and read the updated list below.
components/multi-select/appliance/tag_draft.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class TagDraft extends StatefulWidget {
const TagDraft({super.key});
@override
State<TagDraft> createState() => _TagDraftState();
}
class _TagDraftState extends State<TagDraft> {
List<String> labels = ['Work'];
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceTagInput<String>(
label: 'Labels',
options: const ['Work', 'Home', 'Travel'],
values: labels,
onChanged: (next) => setState(() => labels = next),
),
const SizedBox(height: 12),
Text(
labels.isEmpty ? 'No labels' : 'Draft labels: ${labels.join(', ')}',
),
],
),
);
}
Parameters
ApplianceTagInput API ↗label- Names the collection of selected tags.
options- Labels available to attach.
values- Labels already on the draft.
onChanged- Receives the updated collection after an addition or removal.
Shared behaviour
- Keyboard and focus. Tab to the field, type to narrow the options and use the keyboard to choose a match. The field’s selected labels can also be removed.
- Screen readers. Read the names of the selected labels and the available choices. The summary lists the labels still attached to the draft.
- Direction and type. Add all three labels on a narrow frame and switch direction. Try larger text to see how the selected labels share the space.