Skip to main content

scrollbar_h

Function scrollbar_h 

Source
pub fn scrollbar_h() -> ScrollbarHBuilder
Expand description

§scrollbar_h

Draw a horizontal scrollbar for a scroll viewport.

§Usage

Show and drag the horizontal offset of overflowing content.

§Parameters

  • total — content extent in physical pixels; defaults to controller content.
  • visible — viewport extent in physical pixels; defaults to controller viewport.
  • offset — current scroll offset; defaults to the controller position.
  • thickness — thickness of the scrollbar track.
  • state — scroll controller the scrollbar reads and drives.
  • scrollbar_behavior — visibility behavior (always, auto-hide, hidden).
  • track_color, thumb_color, thumb_hover_color — themed colors.
  • scrollbar_state — shared interaction state; created internally when absent.

Wheel input follows the attached viewport. A custom track without a viewport retains tap, drag and accessibility actions and leaves wheel input to ancestors.

§Examples

use tessera_components::scrollable::{ScrollableController, scrollbar_h};
use tessera_components::theme::material_theme;
use tessera_ui::{Px, PxPosition, remember, tessera};
#[tessera]
fn tracked_content() {
    material_theme().child(|| {
        let controller = remember(ScrollableController::new);
        let offset = PxPosition::new(Px(-40), Px::ZERO);
        controller.with_mut(|controller| controller.set_scroll_position(offset));
        assert_eq!(
            controller.with(|controller| controller.child_position()),
            offset
        );
        scrollbar_h()
            .state(controller)
            .total(Px(600))
            .visible(Px(200));
    });
}