How to customize a message box?


I am running LVGL in version V8.2. In my application, I need to display pop-ups with the following template :

Screenshot from 2023-02-27 17-23-40

Here is the code I am using :

static lv_style_t* snackbar_style_error   = NULL;
lv_style_set_bg_color(snackbar_style_error, lv_color_hex(0xF5E5E4));
lv_style_set_text_color(snackbar_style_error, lv_color_hex(0x5A1605));
lv_style_set_border_width(snackbar_style_error, 0);
lv_style_set_width(snackbar_style_error, 280);

static lv_obj_t* snackbar_obj             = NULL;
snackbar_obj = lv_msgbox_create(screen, "Titre", "Exemple de test", NULL, false);   // screen is the active screen
lv_obj_add_style(snackbar_obj, snackbar_style_error, LV_STATE_DEFAULT);
lv_obj_align(snackbar_obj, LV_ALIGN_BOTTOM_MID, 0, -20);
lv_obj_del_delayed(snackbar_obj, 3000);

Here is the result :

Screenshot from 2023-02-27 17-29-31

To go further, I am facing two problems.

  1. Is it possible to set a specific font for the title and text, independently ?
  2. As you can see on the template, I want the title and text to be slightly shifted to the right to allow the integration of an icon. In my case the icon is a LVGL text symbol but it can be an image if need be. Is it possible to do it ?


I think you should go into the definition of lv_msgbox_create(), understand how this pop-up box is implemented, and then make customized modifications. I think this is relatively simple and achievable.