option function

Component option(
  1. List<Component> children, {
  2. String? label,
  3. String? value,
  4. bool? selected,
  5. bool? disabled,
  6. Key? key,
  7. String? id,
  8. String? classes,
  9. Styles? styles,
  10. Map<String, String>? attributes,
  11. Map<String, EventCallback>? events,
})

The <option> HTML element is used to define an item contained in a <select>, an <optgroup>, or a <datalist> element. As such, <option> can represent menu items in popups and other lists of items in an HTML document.

  • label: This attribute is text for the label indicating the meaning of the option. If the label attribute isn't defined, its value is that of the element text content.
  • value: The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.
  • selected: Indicates that the option is initially selected. If the <option> element is the descendant of a <select> element whose multiple attribute is not set, only one single <option> of this <select> element may have the selected attribute.
  • disabled: If this attribute is set, this option is not checkable. Often browsers grey out such control and it won't receive any browsing event, like mouse clicks or focus-related ones. If this attribute is not set, the element can still be disabled if one of its ancestors is a disabled <optgroup> element.

Implementation

Component option(List<Component> children,
    {String? label,
    String? value,
    bool? selected,
    bool? disabled,
    Key? key,
    String? id,
    String? classes,
    Styles? styles,
    Map<String, String>? attributes,
    Map<String, EventCallback>? events}) {
  return DomComponent(
    tag: 'option',
    key: key,
    id: id,
    classes: classes,
    styles: styles,
    attributes: {
      ...attributes ?? {},
      if (label != null) 'label': label,
      if (value != null) 'value': value,
      if (selected == true) 'selected': '',
      if (disabled == true) 'disabled': '',
    },
    events: events,
    children: children,
  );
}