button function

Component button(
  1. List<Component> children, {
  2. bool? autofocus,
  3. bool? disabled,
  4. ButtonType? type,
  5. VoidCallback? onClick,
  6. Key? key,
  7. String? id,
  8. String? classes,
  9. Styles? styles,
  10. Map<String, String>? attributes,
  11. Map<String, EventCallback>? events,
})

The <button> HTML element is an interactive element activated by a user with a mouse, keyboard, finger, voice command, or other assistive technology. Once activated, it then performs a programmable action, such as submitting a form or opening a dialog.

  • autofocus: Specifies that the button should have input focus when the page loads. Only one element in a document can have this attribute.
  • disabled: Prevents the user from interacting with the button: it cannot be pressed or focused.
  • type: The default behavior of the button.
  • onClick: Callback for the 'click' event.

Implementation

Component button(List<Component> children,
    {bool? autofocus,
    bool? disabled,
    ButtonType? type,
    VoidCallback? onClick,
    Key? key,
    String? id,
    String? classes,
    Styles? styles,
    Map<String, String>? attributes,
    Map<String, EventCallback>? events}) {
  return DomComponent(
    tag: 'button',
    key: key,
    id: id,
    classes: classes,
    styles: styles,
    attributes: {
      ...attributes ?? {},
      if (autofocus == true) 'autofocus': '',
      if (disabled == true) 'disabled': '',
      if (type != null) 'type': type.value,
    },
    events: {
      ...?events,
      ..._events(onClick: onClick),
    },
    children: children,
  );
}