1# Bar (lv_bar)
2
3## Overview
4
5The bar object has a background and an indicator on it. The width of the indicator is set according to the current value of the bar.
6
7Vertical bars can be created if the width of the object is smaller than its height.
8
9Not only the end, but also the start value of the bar can be set, which changes the start position of the indicator.
10
11
12## Parts and Styles
13- `LV_PART_MAIN` The background of the bar and it uses the typical background style properties. Adding padding makes the indicator smaller or larger. The `anim_time` style property sets the animation time if the values set with `LV_ANIM_ON`.
14- `LV_PART_INDICATOR` The indicator itself; also uses all the typical background properties.
15
16## Usage
17
18### Value and range
19A new value can be set by `lv_bar_set_value(bar, new_value, LV_ANIM_ON/OFF)`.
20The value is interpreted in a range (minimum and maximum values) which can be modified with `lv_bar_set_range(bar, min, max)`.
21The default range is 0..100.
22
23The new value in `lv_bar_set_value` can be set with or without an animation depending on the last parameter (`LV_ANIM_ON/OFF`).
24
25### Modes
26The bar can be one of the following modes:
27- `LV_BAR_MODE_NORMAL` A normal bar as described above
28- `LV_BAR_MODE_SYMMETRICAL` Draw the indicator from the zero value to current value. Requires a negative minimum range and positive maximum range.
29- `LV_BAR_MODE_RANGE` Allows setting the start value too by `lv_bar_set_start_value(bar, new_value, LV_ANIM_ON/OFF)`. The start value always has to be smaller than the end value.
30
31## Events
32- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for the following parts:
33    - `LV_BAR_DRAW_PART_INDICATOR` The indicator of the bar
34        - `part`: `LV_PART_INDICATOR`
35        - `draw_area`: area of the indicator
36        - `rect_dsc`
37
38See the events of the [Base object](/widgets/obj) too.
39
40Learn more about [Events](/overview/event).
41
42## Keys
43No *Keys* are processed by the object type.
44
45Learn more about [Keys](/overview/indev).
46
47## Example
48
49```eval_rst
50
51.. include:: ../../../examples/widgets/bar/index.rst
52
53```
54
55## API
56
57```eval_rst
58
59.. doxygenfile:: lv_bar.h
60  :project: lvgl
61
62```
63