Dropdown Menu
Dropdown menus allow users to select an option from a list that appears when the menu is clicked or tapped.
Figma Link
- Web Components
- Flutter
Demo
zeta-web v1.0.0
Web Components
Zeta Dropdown Menu Button places a button that when clicked opens a dropdown menu containing the items passed into it through the items prop.
Storybook
https://design.zebra.com/web/storybook/?path=/docs/components-dropdown--docs
Attributes
| Name | Description | Type | Default |
|---|---|---|---|
| matchParentWidth | Whether the dropdown menu should match the width of its parent. Enabled by default. If disabled, the dropdown menu will size to fit its content. | boolean | true |
| buttonTextMatchesSelected | Whether the button text should update to match the selected item. Default is true. Only applicable for the text-dropdown type. | boolean | true |
| defaultText | The default text to display when no item is selected. Defaults to an empty string if nothing is set. | string | "" |
| open | Controls the state of the dropdown menu. Default is false. | boolean | false |
| items | Array of items to populate the dropdown. Includes label, icon (optional), checked (optional), disabled (optional), and onClick (optional) properties. | Array\<ZetaDropdownItem\> | [ { label: "Auto Item", icon: undefined, checked: false } ] |
| type | The type of dropdown. Options are "text-dropdown", "checkbox-dropdown", and "radio-dropdown". Default is "text-dropdown". | 'number' | 'text' | 'checkbox' | 'textarea' | 'password' | 'time' | 'date' | 'radio' | 'search' | 'text-dropdown' | 'checkbox-dropdown' | 'radio-dropdown' | 'slider' | 'range-selector' | 'select' | 'stepper' | 'integer' | "text-dropdown" |
| direction | The direction of the droppable relative to the anchor. Defaults to bottom if left undefined. | "left" | "right" | "bottom" | "top" | "bottom" |
Inherited Attributes
| Name | Description | Type | Default | Inherited From |
|---|---|---|---|---|
| flavor | The flavor of the dropdown button. Default is "primary". | 'primary' | 'positive' | 'negative' | 'outline' | 'outline-subtle' | 'text' | 'subtle' | "primary" | Flavored |
| name | The name of the dropdown menu button for form control. Default is "default". | string | "default" | FormField |
| autoCapitalize | Whether inputted text is automatically capitalized and how. Only takes effect on non-keyboard entry | "none" | "off" | "sentences" | "on" | "words" | "characters" | undefined | undefined | FormField |
| autoComplete | AutoFill | undefined | undefined | FormField | |
| id | The id of the form control. | string | "" | FormField |
| required | Indicates whether the form control is required to be filled out before submitting the form. | boolean | false | FormField |
| value | The value of the Form Control that is submitted when part of a form. | string | null | null | FormField |
| checked | The state of the Switch or Checkbox that is submitted when part of a form. | boolean | undefined | FormField |
| indeterminate | The state of the Switch or Checkbox defined by a mixed or unknown state. | boolean | false | FormField |
| placeholder | Placeholder text shown when value is empty. | string | undefined | undefined | FormField |
| min | The minimum value for number inputs | number | undefined | undefined | FormField |
| max | The maximum value for number inputs | number | undefined | undefined | FormField |
| readOnly | Placeholder text shown when value is empty. | boolean | undefined | undefined | FormField |
| spellCheck | Whether to spellcheck the input | boolean | "default" | undefined | undefined | FormField |
| disabled | Boolean for if component is disabled.This will apply disabled styles. | boolean | false | FormField |
| rounded | Whether the component is rounded or sharp.When true, rounded will set the border radius of the first child, and any children with class 'contourable-target' to --radius-minimal.Otherwise, this value will be --radius-none. | boolean | undefined | true | Contourable |
| size | Size of component | SizeType | "medium" | Size |
Demo
Widgetbook
Inheritance
Object > DiagnosticableTree > Widget > StatefulWidget > ZetaStatefulWidget
Constructors
Creates a new ZetaDropdown.
ZetaDropdown({Key? key, bool? rounded, required List<ZetaDropdownItem<T>> items, ValueSetter<ZetaDropdownItem<T>>? onChange, T? value, ZetaDropdownMenuType type = ZetaDropdownMenuType.standard, ZetaDropdownSize size = ZetaDropdownSize.standard, Offset offset = Offset.zero, Widget builder(BuildContext context, ZetaDropdownItem<T>? selectedItem, ZetaDropdownController controller)?, VoidCallback? onDismissed, VoidCallback? onOpen, String? semanticDropdownLabel, bool disableButtonSemantics = false, ZetaDropdownMenuPosition? menuPosition})
Properties
| Name | Description | Type | Features |
|---|---|---|---|
| builder | A custom builder for the child of the dropdown. | Widget Function(BuildContext context, ZetaDropdownItem<T>? selectedItem, ZetaDropdownController controller)? | final |
| disableButtonSemantics | If true, Semantics will not include the button variable. | bool | final |
| hashCode | The hash code for this object. | int | no setter inherited |
| items | The items displayed in the dropdown. | List<ZetaDropdownItem<T>> | final |
| key | Controls how one widget replaces another widget in the tree. | Key? | final inherited |
| menuPosition | Override the direction the dropdown menu is rendered. | ZetaDropdownMenuPosition? | final |
| offset | The offset of the dropdown menu from its parent. | Offset | final |
| onChange | Called with the selected value whenever the dropdown is changed. | ValueSetter<ZetaDropdownItem<T>>? | final |
| onDismissed | Called when the dropdown is dismissed. | VoidCallback? | final |
| onOpen | Called when the dropdown is opened. | VoidCallback? | final |
| rounded | Sets rounded or sharp border of the containing box and the icon style. | bool? | final inherited |
| runtimeType | A representation of the runtime type of the object. | Type | no setter inherited |
| semanticDropdownLabel | A semantic label for the dropdown. | String? | final |
| size | The size of the dropdown menu. | ZetaDropdownSize | final |
| type | The type of the dropdown menu. | ZetaDropdownMenuType | final |
| value | The value of the selected item. | T? | final |