How to set the label color of a check box

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


it seems can not change the label of check box color, the docs shows the label use check box’s style LV_CB_STYLE_BG, but it seems not work. @kisvegabor @embeddedt can you help me out?

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?


What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static void InitGeneralCheckBoxStyle(void)
    /* 通用复选框:背景样式 */
    lv_style_copy(&g_GeneralCbBgStyle, &lv_style_transp);
    g_GeneralCbBgStyle.text.color = LV_COLOR_WHITE;
    g_GeneralCbBgStyle.text.opa = LV_OPA_COVER;

    /* 通用复选框:释放样式 */
    lv_style_copy(&g_GeneralCbRelStyle, &lv_style_btn_rel);
    g_GeneralCbRelStyle.text.color = LV_COLOR_WHITE;
    g_GeneralCbRelStyle.text.opa = LV_OPA_COVER;

    /* 通用复选框:按下样式 */
    lv_style_copy(&g_GeneralCbPrStyle, &lv_style_btn_pr);
    g_GeneralCbPrStyle.body.main_color = lv_color_make(100, 150, 255);
    g_GeneralCbPrStyle.body.grad_color = lv_color_make(100, 150, 255);
    g_GeneralCbPrStyle.body.border.part = LV_BORDER_NONE;
    g_GeneralCbPrStyle.text.color = LV_COLOR_WHITE;

    /* 通用复选框:切换释放样式 */
    lv_style_copy(&g_GeneralCbTglRelStyle, &lv_style_btn_tgl_rel);
    g_GeneralCbTglRelStyle.body.main_color = lv_color_make(100, 150, 255);
    g_GeneralCbTglRelStyle.body.grad_color = lv_color_make(100, 150, 255);
    g_GeneralCbTglRelStyle.body.border.part = LV_BORDER_NONE;
    g_GeneralCbTglRelStyle.text.color = LV_COLOR_WHITE;

    /* 通用复选框:切换按下样式 */
    lv_style_copy(&g_GeneralCbTglPrStyle, &lv_style_btn_tgl_pr);
    g_GeneralCbTglPrStyle.body.main_color = lv_color_make(100, 150, 255);
    g_GeneralCbTglPrStyle.body.grad_color = lv_color_make(100, 150, 255);
    g_GeneralCbTglPrStyle.body.border.part = LV_BORDER_NONE;
    g_GeneralCbTglPrStyle.text.color = LV_COLOR_WHITE;

    /* 通用复选框:无效样式 */
    lv_style_copy(&g_GeneralCbInaStyle, &lv_style_btn_ina);

void SetGeneralCheckBoxStyle(lv_obj_t* cb)
    lv_cb_set_style(cb, LV_CB_STYLE_BG, &g_GeneralCbBgStyle);
    lv_cb_set_style(cb, LV_CB_STYLE_BOX_PR, &g_GeneralCbPrStyle);
    lv_cb_set_style(cb, LV_CB_STYLE_BOX_TGL_REL, &g_GeneralCbTglRelStyle);
    lv_cb_set_style(cb, LV_CB_STYLE_BOX_TGL_PR, &g_GeneralCbTglPrStyle);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

At first look your code seems good.

Sorry, not answering the question, but v6 is very old. Can you update to a newer version?

No, it can’t update, but I solved this by overlaying a label with white color. :grinning_face_with_smiling_eyes: