Btnmatrix label not centered when using newline

The general issue is that if I create a button matrix using labels with two lines (such as “My Info\n10”), the first line is centered within the button, but the second line is left-justified to the beginning of the first line. Since the actual contents of the button can vary, I don’t think long_mode text wrapping is an option here.

There was a previous report of the issue in v7 in this thread which sounded like the function lv_btnmatrix_set_align was planned for addition, however on my currently-installed v9.4 there is no such command.

Could this just be a long-standing bug that was never fully addressed, or is there another relevant option that I’m not seeing on the btnmatrix API page?

You can set the text alignment using LV_PART_ITEMS

static const char *btnm_map[] = {"My button\ntext", "2", ""};
lv_obj_t *btnm1 = lv_buttonmatrix_create(lv_screen_active());
lv_buttonmatrix_set_map(btnm1, btnm_map);
lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_text_align(btnm1, LV_TEXT_ALIGN_CENTER, LV_PART_ITEMS);

Screenshot 2026-03-24 at 21.35.21