# Bar (/examples/widgets/bar)



Bar bind value with increment buttons [#bar-bind-value-with-increment-buttons]

<LvglExampleBrief>
  Mutate a bound int subject via 

  `subject_increment_event`

   instead of dragging.
</LvglExampleBrief>

The bar listens to `subject_value`. Each +/- button carries two
`<subject_increment_event>` children — one on `clicked` and one on
`long_pressed_repeat` — so a tap nudges by `step` and a hold keeps repeating.
`min_value`/`max_value` clamp the result and `rollover="true"` wraps around
once the bound is hit; hold past 100 to see it wrap back to 0.

<LvglExample name="lv_example_bar_bind_value" path="widgets/bar/lv_example_bar_bind_value" />

Bar image indicator [#bar-image-indicator]

<LvglExampleBrief>
  Use bitmaps as the bar track and indicator — the bar clips each image to its part.
</LvglExampleBrief>

`bg_image_src` replaces the solid background fill with pixels sampled from a
bitmap. Set it on `selector="main"` for the background track and on
`selector="indicator"` for the filled portion. As the value rises, the indicator
image is revealed left-to-right, showing cyan segments that transition to yellow
then red at the high end. Both images are 280×30, matching the bar widget size.

<LvglExample name="lv_example_bar_img_indicator" path="widgets/bar/lv_example_bar_img_indicator" />

Bar modes [#bar-modes]

<LvglExampleBrief>
  Compare normal, symmetrical, and range modes.
</LvglExampleBrief>

Normal fills from min\_value to value. Symmetrical needs a range that crosses zero and
fills outward from the middle, so positive and negative values pull the indicator in
opposite directions. Range mode draws a band between start\_value and value, useful for
picking an interval rather than a single number.

<LvglExample name="lv_example_bar_modes" path="widgets/bar/lv_example_bar_modes" />

Bar orientation and size [#bar-orientation-and-size]

<LvglExampleBrief>
  Compare horizontal and explicit vertical bars.
</LvglExampleBrief>

The horizontal bar uses the default orientation derived from a wide-and-short size. The
vertical one sets orientation="vertical" explicitly and uses a tall, narrow size so the
indicator grows upward instead of left-to-right.

<LvglExample name="lv_example_bar_orientation" path="widgets/bar/lv_example_bar_orientation" />

Bar styling [#bar-styling]

<LvglExampleBrief>
  Style the MAIN track and the INDICATOR independently, with a gradient fill.
</LvglExampleBrief>

Bar exposes two parts: MAIN (the background track) and INDICATOR (the filled portion).
Each is styled separately via `selector="main"` and `selector="indicator"`. The
indicator style adds a horizontal gradient and a darker inner shadow so the fill
reads as a glossy progress strip on top of the recessed track.

<LvglExample name="lv_example_bar_styling" path="widgets/bar/lv_example_bar_styling" />

Bar value and custom range [#bar-value-and-custom-range]

<LvglExampleBrief>
  Drive the indicator with a custom min/max range.
</LvglExampleBrief>

The first bar uses the default 0..100 range with value 30. The second bar shifts the
range to -20..80 with value 35 to demonstrate that ranges need not start at zero — the
indicator length is computed relative to wherever the range begins.

<LvglExample name="lv_example_bar_value_range" path="widgets/bar/lv_example_bar_value_range" />
