# lv_imagebutton.h (/api/widgets/imagebutton/lv_imagebutton_h)



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

<ApiSummary functions="9" enums="1" variables="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (5)&#x22;,&#x22;Getters (3)&#x22;,&#x22;Other (1)&#x22;]">
  <ApiTab value="Setters (5)">
    <ApiMember kind="function" name="lv_imagebutton_set_src" file="widgets/imagebutton/lv_imagebutton.h" line="68" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L68">
      lv_imagebutton_set_src [#lv_imagebutton_set_src]

      Set images for a state of the image button

      ```c title=" " lineNumbers=1
      void lv_imagebutton_set_src(lv_obj_t *obj, lv_imagebutton_state_t state, const void *src_left, const void *src_mid, const void *src_right)
      ```

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

      | Name        | Type                                             | Description                                                                                              |
      | ----------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
      | `obj`       | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                                                                        |
      | `state`     | <ApiLink name="lv_imagebutton_state_t" />        | for which state set the new image                                                                        |
      | `src_left`  | `const void *`                                   | pointer to an image source for the left side of the button (a C array or path to a file)                 |
      | `src_mid`   | `const void *`                                   | pointer to an image source for the middle of the button (ideally 1px wide) (a C array or path to a file) |
      | `src_right` | `const void *`                                   | pointer to an image source for the right side of the button (a C array or path to a file)                |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_left" file="widgets/imagebutton/lv_imagebutton.h" line="79" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L79">
      lv_imagebutton_set_src_left [#lv_imagebutton_set_src_left]

      Set the left image for a state of the image button

      ```c title=" " lineNumbers=1
      void lv_imagebutton_set_src_left(lv_obj_t *obj, lv_imagebutton_state_t state, const void *src_left)
      ```

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

      | Name       | Type                                             | Description                                                                              |
      | ---------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------- |
      | `obj`      | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                                                        |
      | `state`    | <ApiLink name="lv_imagebutton_state_t" />        | for which state set the new image                                                        |
      | `src_left` | `const void *`                                   | pointer to an image source for the left side of the button (a C array or path to a file) |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_right" file="widgets/imagebutton/lv_imagebutton.h" line="88" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L88">
      lv_imagebutton_set_src_right [#lv_imagebutton_set_src_right]

      Set the right image for a state of the image button

      ```c title=" " lineNumbers=1
      void lv_imagebutton_set_src_right(lv_obj_t *obj, lv_imagebutton_state_t state, const void *src_right)
      ```

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

      | Name        | Type                                             | Description                                                                               |
      | ----------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------- |
      | `obj`       | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                                                         |
      | `state`     | <ApiLink name="lv_imagebutton_state_t" />        | for which state set the new image                                                         |
      | `src_right` | `const void *`                                   | pointer to an image source for the right side of the button (a C array or path to a file) |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_mid" file="widgets/imagebutton/lv_imagebutton.h" line="97" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L97">
      lv_imagebutton_set_src_mid [#lv_imagebutton_set_src_mid]

      Set the middle image for a state of the image button

      ```c title=" " lineNumbers=1
      void lv_imagebutton_set_src_mid(lv_obj_t *obj, lv_imagebutton_state_t state, const void *src_mid)
      ```

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

      | Name      | Type                                             | Description                                                                           |
      | --------- | ------------------------------------------------ | ------------------------------------------------------------------------------------- |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                                                     |
      | `state`   | <ApiLink name="lv_imagebutton_state_t" />        | for which state set the new image                                                     |
      | `src_mid` | `const void *`                                   | pointer to an image source for the middle of the button (a C array or path to a file) |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_state" file="widgets/imagebutton/lv_imagebutton.h" line="104" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L104">
      lv_imagebutton_set_state [#lv_imagebutton_set_state]

      Use this function instead of `lv_obj_add/remove_state` to set a state manually

      ```c title=" " lineNumbers=1
      void lv_imagebutton_set_state(lv_obj_t *obj, lv_imagebutton_state_t state)
      ```

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

      | Name    | Type                                             | Description                       |
      | ------- | ------------------------------------------------ | --------------------------------- |
      | `obj`   | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object |
      | `state` | <ApiLink name="lv_imagebutton_state_t" />        | the new state                     |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (3)">
    <ApiMember kind="function" name="lv_imagebutton_get_src_left" file="widgets/imagebutton/lv_imagebutton.h" line="116" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L116">
      lv_imagebutton_get_src_left [#lv_imagebutton_get_src_left]

      Get the left image in a given state

      ```c title=" " lineNumbers=1
      const void * lv_imagebutton_get_src_left(lv_obj_t *obj, lv_imagebutton_state_t state)
      ```

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

      | Name    | Type                                             | Description                                                    |
      | ------- | ------------------------------------------------ | -------------------------------------------------------------- |
      | `obj`   | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                              |
      | `state` | <ApiLink name="lv_imagebutton_state_t" />        | the state where to get the image (from `lv_button_state_t`) \` |

      **Returns:** `const void *` — pointer to the left image source (a C array or path to a file)
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_get_src_middle" file="widgets/imagebutton/lv_imagebutton.h" line="124" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L124">
      lv_imagebutton_get_src_middle [#lv_imagebutton_get_src_middle]

      Get the middle image in a given state

      ```c title=" " lineNumbers=1
      const void * lv_imagebutton_get_src_middle(lv_obj_t *obj, lv_imagebutton_state_t state)
      ```

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

      | Name    | Type                                             | Description                                                    |
      | ------- | ------------------------------------------------ | -------------------------------------------------------------- |
      | `obj`   | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                              |
      | `state` | <ApiLink name="lv_imagebutton_state_t" />        | the state where to get the image (from `lv_button_state_t`) \` |

      **Returns:** `const void *` — pointer to the middle image source (a C array or path to a file)
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_get_src_right" file="widgets/imagebutton/lv_imagebutton.h" line="132" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L132">
      lv_imagebutton_get_src_right [#lv_imagebutton_get_src_right]

      Get the right image in a given state

      ```c title=" " lineNumbers=1
      const void * lv_imagebutton_get_src_right(lv_obj_t *obj, lv_imagebutton_state_t state)
      ```

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

      | Name    | Type                                             | Description                                                    |
      | ------- | ------------------------------------------------ | -------------------------------------------------------------- |
      | `obj`   | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an image button object                              |
      | `state` | <ApiLink name="lv_imagebutton_state_t" />        | the state where to get the image (from `lv_button_state_t`) \` |

      **Returns:** `const void *` — pointer to the left image source (a C array or path to a file)
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (1)">
    <ApiMember kind="function" name="lv_imagebutton_create" file="widgets/imagebutton/lv_imagebutton.h" line="47" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L47">
      lv_imagebutton_create [#lv_imagebutton_create]

      Create an image button object

      ```c title=" " lineNumbers=1
      lv_obj_t * lv_imagebutton_create(lv_obj_t *parent)
      ```

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

      | Name     | Type                                             | Description                                                         |
      | -------- | ------------------------------------------------ | ------------------------------------------------------------------- |
      | `parent` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object, it will be the parent of the new image button |

      **Returns:** <ApiLink name="lv_obj_t" display="lv_obj_t *" /> — pointer to the created image button
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="lv_imagebutton_state_t" file="widgets/imagebutton/lv_imagebutton.h" line="23" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L23">
  lv_imagebutton_state_t [#lv_imagebutton_state_t]

  | Name                                    |
  | --------------------------------------- |
  | `LV_IMAGEBUTTON_STATE_RELEASED`         |
  | `LV_IMAGEBUTTON_STATE_PRESSED`          |
  | `LV_IMAGEBUTTON_STATE_DISABLED`         |
  | `LV_IMAGEBUTTON_STATE_CHECKED_RELEASED` |
  | `LV_IMAGEBUTTON_STATE_CHECKED_PRESSED`  |
  | `LV_IMAGEBUTTON_STATE_CHECKED_DISABLED` |
  | `LV_IMAGEBUTTON_STATE_NUM`              |
</ApiMember>

<TypeUsedBy name="lv_imagebutton_state_t" count="8">
  * `lv_imagebutton_set_src` — param `state`
  * `lv_imagebutton_set_src_left` — param `state`
  * `lv_imagebutton_set_src_right` — param `state`
  * `lv_imagebutton_set_src_mid` — param `state`
  * `lv_imagebutton_set_state` — param `state`
  * `lv_imagebutton_get_src_left` — param `state`
  * `lv_imagebutton_get_src_middle` — param `state`
  * `lv_imagebutton_get_src_right` — param `state`
</TypeUsedBy>

Variables [#variables]

<ApiMember kind="variable" name="lv_imagebutton_class" file="widgets/imagebutton/lv_imagebutton.h" line="36" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/imagebutton/lv_imagebutton.h#L36">
  lv_imagebutton_class [#lv_imagebutton_class]

  ```c title=" " lineNumbers=1
  const lv_obj_class_t lv_imagebutton_class
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_obj.h&#x22;]" includedBy="[&#x22;lv_imagebutton_private.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;]" />
