# lv_theme.h (/api/themes/lv_theme_h)



<RelatedHeaders name="lv_theme_private.h" isPrivate="false" />

<ApiSummary functions="13" typedefs="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (3)&#x22;,&#x22;Getters (6)&#x22;,&#x22;Other (4)&#x22;]">
  <ApiTab value="Setters (3)">
    <ApiMember kind="function" name="lv_theme_set_parent" file="themes/lv_theme.h" line="65" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L65">
      lv_theme_set_parent [#lv_theme_set_parent]

      Set a base theme for a theme. The styles from the base them will be added before the styles of the current theme. Arbitrary long chain of themes can be created by setting base themes.

      ```c title=" " lineNumbers=1
      void lv_theme_set_parent(lv_theme_t *theme, lv_theme_t *parent)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                                 | Description                               |
      | -------- | ---------------------------------------------------- | ----------------------------------------- |
      | `theme`  | <ApiLink name="lv_theme_t" display="lv_theme_t *" /> | pointer to theme which base should be set |
      | `parent` | <ApiLink name="lv_theme_t" display="lv_theme_t *" /> | pointer to the base theme                 |
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_set_apply_cb" file="themes/lv_theme.h" line="73" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L73">
      lv_theme_set_apply_cb [#lv_theme_set_apply_cb]

      Set an apply callback for a theme. The apply callback is used to add styles to different objects

      ```c title=" " lineNumbers=1
      void lv_theme_set_apply_cb(lv_theme_t *theme, lv_theme_apply_cb_t apply_cb)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                                 | Description                                   |
      | ---------- | ---------------------------------------------------- | --------------------------------------------- |
      | `theme`    | <ApiLink name="lv_theme_t" display="lv_theme_t *" /> | pointer to theme which callback should be set |
      | `apply_cb` | <ApiLink name="lv_theme_apply_cb_t" />               | pointer to the callback                       |
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_set_external_data" file="themes/lv_theme.h" line="129" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L129">
      lv_theme_set_external_data [#lv_theme_set_external_data]

      Attaches external user data and destructor callback to the theme.

      Associates custom user data with an LVGL theme and specifies a destructor function that will be automatically invoked when the theme is deleted to properly clean up the associated resources.

      ```c title=" " lineNumbers=1
      void lv_theme_set_external_data(lv_theme_t *theme, void *data, void(*free_cb)(void *data))
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                                 | Description                                                                                                                         |
      | --------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
      | `theme`   | <ApiLink name="lv_theme_t" display="lv_theme_t *" /> | Pointer to theme which callback should be set                                                                                       |
      | `data`    | `void *`                                             | User-defined data pointer to associate with the theme                                                                               |
      | `free_cb` | `void(*)(void *data)`                                | Callback function for cleaning up ext\_data when theme is deleted. Receives ext\_data as parameter. NULL means no cleanup required. |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (6)">
    <ApiMember kind="function" name="lv_theme_get_from_obj" file="themes/lv_theme.h" line="50" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L50">
      lv_theme_get_from_obj [#lv_theme_get_from_obj]

      Get the theme assigned to the display of the object

      ```c title=" " lineNumbers=1
      lv_theme_t * lv_theme_get_from_obj(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description               |
      | ----- | ------------------------------------------------ | ------------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a theme object |

      **Returns:** <ApiLink name="lv_theme_t" display="lv_theme_t *" /> — the theme of the object's display (can be NULL)
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_get_font_small" file="themes/lv_theme.h" line="80" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L80">
      lv_theme_get_font_small [#lv_theme_get_font_small]

      Get the small font of the theme

      ```c title=" " lineNumbers=1
      const lv_font_t * lv_theme_get_font_small(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |

      **Returns:** <ApiLink name="lv_font_t" display="const lv_font_t *" /> — pointer to the font
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_get_font_normal" file="themes/lv_theme.h" line="86" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L86">
      lv_theme_get_font_normal [#lv_theme_get_font_normal]

      Get the normal font of the theme

      ```c title=" " lineNumbers=1
      const lv_font_t * lv_theme_get_font_normal(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |

      **Returns:** <ApiLink name="lv_font_t" display="const lv_font_t *" /> — pointer to the font
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_get_font_large" file="themes/lv_theme.h" line="93" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L93">
      lv_theme_get_font_large [#lv_theme_get_font_large]

      Get the subtitle font of the theme

      ```c title=" " lineNumbers=1
      const lv_font_t * lv_theme_get_font_large(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |

      **Returns:** <ApiLink name="lv_font_t" display="const lv_font_t *" /> — pointer to the font
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_get_color_primary" file="themes/lv_theme.h" line="100" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L100">
      lv_theme_get_color_primary [#lv_theme_get_color_primary]

      Get the primary color of the theme

      ```c title=" " lineNumbers=1
      lv_color_t lv_theme_get_color_primary(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |

      **Returns:** <ApiLink name="lv_color_t" /> — the color
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_get_color_secondary" file="themes/lv_theme.h" line="107" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L107">
      lv_theme_get_color_secondary [#lv_theme_get_color_secondary]

      Get the secondary color of the theme

      ```c title=" " lineNumbers=1
      lv_color_t lv_theme_get_color_secondary(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |

      **Returns:** <ApiLink name="lv_color_t" /> — the color
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (4)">
    <ApiMember kind="function" name="lv_theme_create" file="themes/lv_theme.h" line="36" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L36">
      lv_theme_create [#lv_theme_create]

      Creates a new theme

      ```c title=" " lineNumbers=1
      lv_theme_t * lv_theme_create(void)
      ```

      **Returns:** <ApiLink name="lv_theme_t" display="lv_theme_t *" /> — the new theme or NULL if allocation failed
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_copy" file="themes/lv_theme.h" line="43" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L43">
      lv_theme_copy [#lv_theme_copy]

      Copy 'src' theme into 'dst'

      ```c title=" " lineNumbers=1
      void lv_theme_copy(lv_theme_t *dst, const lv_theme_t *src)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                       | Description                      |
      | ----- | ---------------------------------------------------------- | -------------------------------- |
      | `dst` | <ApiLink name="lv_theme_t" display="lv_theme_t *" />       | pointer to the destination theme |
      | `src` | <ApiLink name="lv_theme_t" display="const lv_theme_t *" /> | pointer to the source theme      |
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_apply" file="themes/lv_theme.h" line="56" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L56">
      lv_theme_apply [#lv_theme_apply]

      Apply the active theme on an object

      ```c title=" " lineNumbers=1
      void lv_theme_apply(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description          |
      | ----- | ------------------------------------------------ | -------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object |
    </ApiMember>

    <ApiMember kind="function" name="lv_theme_delete" file="themes/lv_theme.h" line="114" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L114">
      lv_theme_delete [#lv_theme_delete]

      Delete a theme

      ```c title=" " lineNumbers=1
      void lv_theme_delete(lv_theme_t *theme)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                                 | Description          |
      | ------- | ---------------------------------------------------- | -------------------- |
      | `theme` | <ApiLink name="lv_theme_t" display="lv_theme_t *" /> | the theme to destroy |
    </ApiMember>
  </ApiTab>
</ApiTabs>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_theme_apply_cb_t" file="themes/lv_theme.h" line="26" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/themes/lv_theme.h#L26">
  lv_theme_apply_cb_t [#lv_theme_apply_cb_t]

  ```c title=" " lineNumbers=1
  typedef void(* lv_theme_apply_cb_t) (lv_theme_t *, lv_obj_t *)
  ```
</ApiMember>

<TypeUsedBy name="lv_theme_apply_cb_t" count="1">
  * `lv_theme_set_apply_cb` — param `apply_cb`
</TypeUsedBy>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_obj.h&#x22;, &#x22;lv_theme_default.h&#x22;, &#x22;lv_theme_mono.h&#x22;, &#x22;lv_theme_simple.h&#x22;]" includedBy="[&#x22;lv_theme_default.h&#x22;, &#x22;lv_theme_private.h&#x22;, &#x22;lv_theme_mono.h&#x22;, &#x22;lv_theme_simple.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
