How to customize the loading indicator in Vaadin

This topic is the discussion thread for the Vaadin documentation page How to customize the loading indicator in Vaadin.

Questions, feedback, and comments are welcome here.

Why doesn't work thise code?

Or should i add some annotations?

For a custom loading indicator shown as rotating circle:

Add to styles.css

  .v-loading-indicator {
    position: fixed;
    inset: auto;             /* reset left/right/top */
    left: calc(50% - 100px); /* 50% - half width */
    top: calc(50% - 100px);  /* 50% - half height */
    width: 200px !important;
    height: 200px !important;
    display: block;
    box-sizing: border-box;

    border: 12px solid rgba(0, 0, 0, 0.2);
    border-top-color: maroon;
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.1);

    animation: spin 0.8s linear infinite;
  }

  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }

  /* Disable default theme, annoying scroller shows. */
  body{
    overflow: hidden;
}

Application.java

public class Application implements VaadinServiceInitListener
{
@Override
public void serviceInit(ServiceInitEvent serviceInitEvent)
{
serviceInitEvent.getSource().addUIInitListener(uiInitEvent -> {
LoadingIndicatorConfiguration conf = uiInitEvent.getUI().getLoadingIndicatorConfiguration();
// disable default theme -> loading indicator isn’t shown
conf.setApplyDefaultTheme(false);
});

}

}

This no longer appears to work correctly in vaadin 25.

Dialogs still appear nice and bright 'above' the modal curtain (and worse can be interacted with), and a custom component I have added to the loading v-loading-indicator div is displayed behind the dialog. Any tips on fixing, or is this something you might address in an upcoming release?

The complete 'modality curtain' is great from our perspective, as we know the users are locked out from further interaction whilst a longer running process is happening, and we don't have to think about it too much or code too protectively.

Please file an issue here: https://github.com/vaadin/flow/issues

Raised ticket #23173

To solve the issue (Vaadin 25.2.3.), add opacity: 1; to v-loading-indicator css class definition. e.g.:

.v-loading-indicator {
  opacity: 1 !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: auto !important;
  z-index: 2147483647;
}


My loading indicator (where progress_indicator.gif is a simple animated gif of spinning wheel):

.v-loading-indicator {
   opacity: 1 !important;
   position: fixed; /* Occupy whole screen even if scrolled */
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   /* Eat mouse events when visible, doesn't prevent scrolling */
   pointer-events: auto !important;
   background-image:url("./img/progress_indicator.gif");
   background-repeat: no-repeat;
   background-position: 50% 50%;
   background-size: 35px;
   background-color: rgba(0, 0, 0, 0.05);
   z-index: 2147483647;
}

Hi.

Just upgraded from Vaadin 25.0.7 to 25.2.7, and can confirm the loading indicator behaviour has issues again.

This time, the 'opacity' seems to be stuck at 0 through all three transitions, and so we never see the loading indicator.

Note that 'pointer-events' is stuck at none as well, which means the clicks make it to the underlying buttons.

It can be fixed through custom css, but obviously I would prefer it addressed in the framework itself.

Cheers,

Lee.

We would be grateful if you can open a new issue about this at https://github.com/vaadin/flow/issues

Also, this is hard to debug without the actual custom CSS you have in the app.

Thanks.

I have raised the following ticket: https://github.com/vaadin/flow/issues/25705