fossui
Components

Combobox

A text field with a filtered dropdown, for free text, single pick, or multiple picks.

A combobox pairs a text input with a dropdown that filters as you type. Three widgets cover the common shapes: FossAutocomplete for free text with hints, FossCombobox for a single pick from a fixed list, and FossMultiCombobox for several picks shown as chips. All read colors, type, and metrics from the theme.

import 'package:fossui/fossui.dart';

FossAutocomplete(
  label: 'Fruit',
  hintText: 'Type to filter',
  items: const ['Apple', 'Banana', 'Cherry'],
  onChanged: (value) => setState(() => fruit = value),
);

Autocomplete

FossAutocomplete filters a list of string suggestions but accepts any typed value: the items are hints, not a constraint. The value is the field string, reported through onChanged. There is no selection check and no multiple pick.

FossAutocomplete(
  label: 'City',
  hintText: 'Start typing',
  items: cities,
  showClear: true,
  onChanged: (value) => setState(() => query = value),
);

Single select

FossCombobox picks one value from a fixed list of FossComboboxItems. The value is the selected item, not the raw text, so pass value and rebuild on onSelected. Each row carries a check when picked, and picking closes the popup.

FossCombobox<String>(
  label: 'Team',
  hintText: 'Search teams',
  value: team,
  onSelected: (v) => setState(() => team = v),
  items: const [
    FossComboboxItem(value: 'design', label: 'Design'),
    FossComboboxItem(value: 'eng', label: 'Engineering'),
  ],
);

Multiple select

FossMultiCombobox holds several picks at once, shown as removable chips. The value is the set of selected items. Typing filters the list, picking toggles a chip and keeps the popup open, and Backspace on an empty input removes the last chip.

FossMultiCombobox<String>(
  label: 'Tags',
  hintText: 'Add tags',
  values: tags,
  onSelected: (v) => setState(() => tags = v),
  items: const [
    FossComboboxItem(value: 'design', label: 'Design'),
    FossComboboxItem(value: 'eng', label: 'Engineering'),
  ],
);

Custom filter

By default the dropdown matches the query as a case-insensitive substring of the label. Pass filter to change how a row is matched, for example to match the start of the label only.

FossCombobox<String>(
  label: 'Country',
  value: country,
  filter: (label, query) =>
      label.toLowerCase().startsWith(query.toLowerCase()),
  onSelected: (v) => setState(() => country = v),
  items: countries,
);

Sizes

size sets the field height and type scale: sm, md (the default), or lg.

FossCombobox<String>(
  size: FossTextFieldSize.sm,
  value: team,
  onSelected: (v) => setState(() => team = v),
  items: teams,
);

API

FossAutocomplete

PropTypeDefaultDescription
itemsList<String>requiredThe suggestions to filter as the user types.
controllerTextEditingController?nullHolds the editable text. Created internally when null.
focusNodeFocusNode?nullManages keyboard focus. Created internally when null.
sizeFossTextFieldSizemdThe field height and type scale.
labelString?nullLabel rendered above the field.
hintTextString?nullPlaceholder shown while the field is empty.
errorTextString?nullWhen non-null, marks the field invalid.
enabledbooltrueWhether the field accepts input.
showTriggerboolfalseShow the trailing chevron that opens the list.
showClearboolfalseShow a trailing clear button while the field is non-empty.
startAddonWidget?nullOptional leading widget, typically a search glyph.
filterbool Function(String label, String query)?nullOverrides the default substring match.
onChangedValueChanged<String>?nullCalled whenever the field text changes, including on a pick.
styleFossComboboxStyle?nullPer-instance overrides on the theme.

FossCombobox<T>

PropTypeDefaultDescription
itemsList<FossComboboxItem<T>>requiredThe options to choose from.
valueT?nullThe picked value, or null when nothing is selected.
onSelectedValueChanged<T?>?nullCalled with the picked value. A null callback disables the field.
focusNodeFocusNode?nullManages keyboard focus. Created internally when null.
sizeFossTextFieldSizemdThe field height and type scale.
labelString?nullLabel rendered above the field.
hintTextString?nullPlaceholder shown while the field is empty.
errorTextString?nullWhen non-null, marks the field invalid.
enabledbooltrueWhether the field accepts input. Disabled when false or onSelected is null.
showClearboolfalseShow a trailing clear button while a value is selected.
startAddonWidget?nullOptional leading widget, typically a search glyph.
filterbool Function(String label, String query)?nullOverrides the default substring match.
styleFossComboboxStyle?nullPer-instance overrides on the theme.

FossMultiCombobox<T>

PropTypeDefaultDescription
itemsList<FossComboboxItem<T>>requiredThe options to choose from.
valuesSet<T>{}The current picks.
onSelectedValueChanged<Set<T>>?nullCalled with the next set when a pick is toggled. A null callback disables the field.
focusNodeFocusNode?nullManages keyboard focus. Created internally when null.
sizeFossTextFieldSizemdThe field height and type scale.
labelString?nullLabel rendered above the field.
hintTextString?nullPlaceholder shown while no picks and the input is empty.
errorTextString?nullWhen non-null, marks the field invalid.
enabledbooltrueWhether the field accepts input. Disabled when false or onSelected is null.
startAddonWidget?nullOptional leading widget, typically a search glyph.
filterbool Function(String label, String query)?nullOverrides the default substring match.
styleFossComboboxStyle?nullPer-instance overrides on the theme.

FossComboboxItem<T>

PropTypeDefaultDescription
valueTrequiredThe identity reported when the option is picked, compared by ==.
labelStringrequiredThe row and chip text, and the string the filter matches against.
iconWidget?nullOptional leading glyph rendered before the label.
enabledbooltrueWhether the option can be picked. A disabled option dims and ignores taps.

FossTextFieldSize

sm, md, lg.

Live demo

Open the interactive gallery to try every variant, size, and state with live knobs.

On this page