# lv_imagebutton.h (/api/public/widgets/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="public/widgets/lv_imagebutton.h" line="69" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L69">
      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) **May** be `NULL`. When NULL the left side is not drawn.              |
      | `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) **May** be `NULL`. When NULL the middle is not drawn. |
      | `src_right` | `const void *`                                   | pointer to an image source for the right side of the button (a C array or path to a file) **May** be `NULL`. When NULL the right side is not drawn.            |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_left" file="public/widgets/lv_imagebutton.h" line="80" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L80">
      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) **May** be `NULL`. When NULL the left side is not drawn. |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_right" file="public/widgets/lv_imagebutton.h" line="89" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L89">
      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) **May** be `NULL`. When NULL the right side is not drawn. |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_src_mid" file="public/widgets/lv_imagebutton.h" line="98" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L98">
      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) **May** be `NULL`. When NULL the middle is not drawn. |
    </ApiMember>

    <ApiMember kind="function" name="lv_imagebutton_set_state" file="public/widgets/lv_imagebutton.h" line="105" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L105">
      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="public/widgets/lv_imagebutton.h" line="117" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L117">
      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 <ApiLink name="lv_imagebutton_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="public/widgets/lv_imagebutton.h" line="125" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L125">
      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="public/widgets/lv_imagebutton.h" line="133" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L133">
      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="public/widgets/lv_imagebutton.h" line="48" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/lv_imagebutton.h#L48">
      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 a parent widget **May** be `NULL`.. When NULL, the widget is created as a screen on the default display. |

      **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="public/widgets/lv_imagebutton.h" line="23" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/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="public/widgets/lv_imagebutton.h" line="36" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/widgets/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;lvgl.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.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_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_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_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_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
