Skip to content

GemButton

Button enables user interaction through simple clicks or taps, triggering actions or tasks.

Usage Example

/* (c) https://github.com/MontiCore/monticore */
package example_basic;

import mc.fenix.basic.GemButton;
import common.ExamplePage;
import mc.fenix.arrange.GemColumn;

page GemButtonExample() {
  @ExamplePage(
    component = @GemColumn(components = [
      @GemButton(label = "windows alert", leftClick = alert()),
      @GemButton(label = "Cannot click me", disabled = true)
    ]),
    basePath = "example_basic",
    componentName = "GemButtonExample"
  );
}
GemButtonExample

TypeScript implementation:

package example_basic;

import umlp.guiutil.HTMLUtils;
import umlp.jsweet.extension.annotation.Component;

import java.util.function.Consumer;

@Component
public class GemButtonExample extends GemButtonExampleTOP {

  @Override
  public Consumer<Void> alert() {
    return $ -> {
      HTMLUtils.alert("Hello");
    };
  }
}

GUI Model

component GemButton(
  String height = "fit-content",
  String width = "fit-content",
  String margin = "0.5ch",
  String label = "",
  String ariaLabel = "",
  List<GUIViewElement> content,
  boolean disabled = false,
  boolean active = false,
  Event<Void> leftClick,

  String routerLink = null,
  String routerLinkActive = null
)
Name Type Description Default value
height String Height of the component in px, %, vh. By default collapses to a minimal possible height or takes up all available space depending on context. "fit-content"
width String Width of the component in px, %, vh. By default collapses to a minimal possible width or takes up all available space depending on context. "fit-content"
margin String Margin around the component. By default provides a small spacing. "0.5ch"
label String Button text. ""
ariaLabel String Accessible name for screen readers. Set it when the button has no visible text, e.g. if content only contains an icon. ""
content List<GUIViewElement> Button content if a more complex element than text is required. If label and content are both set, only content is shown.
disabled boolean If true, the button cannot be clicked. false
active boolean If true, the button is highlighted as the currently selected one, e.g. the active category in a navigation bar. false
leftClick Event<Void> Callback that is executed when a button is clicked.
routerLink String null
routerLinkActive String null