Transitions and gradients

Hey, is it possible to define a transition when switching themes?

Also would it be possible to define a button with a gradient background :thinking:

I don’t think it’s possible to animate the theme transition.

But it is possible to define gradient backgrounds for buttons

Try something like

vaadin-button {
    background: linear-gradient(32.15deg, #FF006B 12.1%, #FC5B00 49.94%, #F9BD00 88.57%);
    color: #fff;
    font-weight: 800;

If you only want to style one button, give it a class name and apply the styles to that

Any way to do this with Flow?

I mean, there’s getStyle()#set

You are better off using your theme / styles.css instead of using the java API for styling.

Alright, managed to get something going

Is there a way I can add a css class to the entire container so I can do some theme stuff by myself? seems a bit more logical

Call addClassName() on any component to add CSS class names (well, most components)

Hmm this doesn’t achieve the result I’m looking for

Changing the theme is a bit more than just adding a couple classes to the base container

Seems like it’s more of a setAttribute(“theme”, whatever)

The theme is basically just an attribute at the body element. So you can either change or expand that or apply css classes to the body to have some global effects. The theme itself is then just normal css in your global style. (e.g.

[theme~=“dark”] {
–lumo-primary-color: pink;

You could even change the html attribute, if you want to and apply something like
to the body element using the Element API on the UI (or some other global-like container), setting the attribute via Java and then select it in css

[theme-variant~=“dark”] {
–lumo-primary-color: pink;