1# Image button (lv_imgbtn)
2
3## Overview
4
5The Image button is very similar to the simple 'Button' object. The only difference is that it displays user-defined images in each state instead of drawing a rectangle.
6
7You can set a left, right and center image, and the center image will be repeated to match the width of the object.
8
9
10
11## Parts and Styles
12- `LV_PART_MAIN` Refers to the image(s). If background style properties are used, a rectangle will be drawn behind the image button.
13
14## Usage
15
16### Image sources
17To set the image in a state, use the `lv_imgbtn_set_src(imgbtn, LV_IMGBTN_STATE_..., src_left, src_center, src_right)`.
18
19The image sources work the same as described in the [Image object](/widgets/core/img) except that "Symbols" are not supported by the Image button.
20Any of the sources can `NULL`.
21
22The possible states are:
23- `LV_IMGBTN_STATE_RELEASED`
24- `LV_IMGBTN_STATE_PRESSED`
25- `LV_IMGBTN_STATE_DISABLED`
26- `LV_IMGBTN_STATE_CHECKED_RELEASED`
27- `LV_IMGBTN_STATE_CHECKED_PRESSED`
28- `LV_IMGBTN_STATE_CHECKED_DISABLED`
29
30If you set sources only in `LV_IMGBTN_STATE_RELEASED`, these sources will be used in other states too.
31If you set e.g. `LV_IMGBTN_STATE_PRESSED` they will be used in pressed state instead of the released images.
32
33
34### States
35Instead of the regular `lv_obj_add/clear_state()` functions the `lv_imgbtn_set_state(imgbtn, LV_IMGBTN_STATE_...)` functions should be used to manually set a state.
36
37
38## Events
39- `LV_EVENT_VALUE_CHANGED` Sent when the button is toggled.
40
41Learn more about [Events](/overview/event).
42
43## Keys
44- `LV_KEY_RIGHT/UP`  Go to toggled state if `LV_OBJ_FLAG_CHECKABLE` is enabled.
45- `LV_KEY_LEFT/DOWN`  Go to non-toggled state if `LV_OBJ_FLAG_CHECKABLE` is enabled.
46- `LV_KEY_ENTER` Clicks the button
47
48
49Learn more about [Keys](/overview/indev).
50
51## Example
52
53```eval_rst
54
55.. include:: ../../../examples/widgets/imgbtn/index.rst
56
57```
58
59## API
60
61```eval_rst
62
63.. doxygenfile:: lv_imgbtn.h
64  :project: lvgl
65
66```
67