@CssImport(value = "./styles/material/theme.css", themeFor = "vaadin-button")
public class MyCustomButton extends Button {
// ...
}
@CssImport(value = "./styles/material/theme.css", themeFor = "vaadin-button")
public class MyCustomButton extends Button {
public MyCustomButton(String text) {
super(text);
addClassName("custom-button");
}
protected void applyTheme() {
getStyle().set("background-color", "blue");
getStyle().set("color", "white");
getStyle().set("font-size", "14px");
}
protected void onHover() {
getStyle().set("background-color", "lightblue");
}
protected void onPress() {
getStyle().set("background-color", "darkblue");
}
}
public class MainView extends VerticalLayout {
public MainView() {
MyCustomButton customButton = new MyCustomButton("Click me!");
customButton.addClickListener(e -> Notification.show("Button clicked!"));
add(customButton);
}
}