ScrollArea
Composes a scrollable viewport with caller-styled scrollbars, thumbs, and corner.
Loading interactive demo…
let area = ScrollArea::new("log");
area.viewport().h(160.0).overflow_hidden()#Import
Import ScrollArea from quickgui.
use quickgui::*;#Usage
let area = ScrollArea::new("log");
area.viewport().h(160.0).overflow_hidden()#Anatomy
ScrollArea::rootScrollArea::viewportScrollArea::contentScrollArea::scrollbarScrollArea::thumbScrollArea::corner
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
ScrollArea
View sourcepub fn new(root_id: impl Into<ElementId>) -> Selfkeep_mountedpub const fn keep_mounted(mut self, keep_mounted: bool) -> Self—
Keep a scrollbar mounted while its axis does not overflow. The default unmounts it, matching Base UI's `keepMounted={false}`. A kept scrollbar is hidden from assistive technology while its axis cannot scroll, so a mounted-but-useless scrollbar is never announced.
pub const fn keep_mounted(mut self, keep_mounted: bool) -> SelfView sourceis_keep_mountedpub const fn is_keep_mounted(self) -> bool—
root_idpub const fn root_id(self) -> ElementId—
viewport_idpub fn viewport_id(self) -> ElementId—
content_idpub fn content_id(self) -> ElementId—
scrollbar_idpub fn scrollbar_id(self, orientation: ScrollAreaOrientation) -> ElementId—
Configures scrollbar id for this part.
pub fn scrollbar_id(self, orientation: ScrollAreaOrientation) -> ElementIdView sourcethumb_idpub fn thumb_id(self, orientation: ScrollAreaOrientation) -> ElementId—
Configures thumb id for this part.
pub fn thumb_id(self, orientation: ScrollAreaOrientation) -> ElementIdView sourcecorner_idpub fn corner_id(self) -> ElementId—
shows_scrollbarpub fn shows_scrollbar( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, ) -> bool—
Whether a scrollbar for `orientation` should be mounted at all.
pub fn shows_scrollbar( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, ) -> boolView sourceshows_cornerpub fn shows_corner(self, state: &ScrollAreaState) -> bool—
Whether the corner between two scrollbars should be mounted.
pub fn shows_corner(self, state: &ScrollAreaState) -> boolView sourceScrollArea::root_with
View sourcepub fn root_with(self, root: Element) -> ElementDecorate an application-owned root without adding layout or appearance.
ScrollArea::root
View sourcepub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
ScrollArea::viewport_with
View sourcepub fn viewport_with(self, viewport: Element) -> ElementDecorate the application-owned scroll container. The viewport clips its content on both axes and carries the ScrollView role. The caller places the content by translating [`Self::content_with`] with the retained offset, which keeps scrolling paint-only and keeps QuickGUI's built-in overlay scrollbar out of a component whose scrollbars the application draws itself.
ScrollArea::viewport
View sourcepub fn viewport(self) -> ElementCreate the unstyled viewport part. Use [`Self::viewport_with`] to supply an existing element.
ScrollArea::content_with
View sourcepub fn content_with(self, content: Element) -> ElementDecorate the application-owned scrolled content. Translate it by the negated [`ScrollAreaState::offset`]; QuickGUI adds no transform of its own so the application keeps full control of the motion.
ScrollArea::content
View sourcepub fn content(self) -> ElementCreate the unstyled content part. Use [`Self::content_with`] to supply an existing element.
ScrollArea::scrollbar_with
View sourcepub fn scrollbar_with( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, scrollbar: Element, ) -> ElementDecorate one application-owned scrollbar track. The track projects the ScrollBar role with the exact current position, the scrollable range, and its orientation. It is not focusable: a scrollbar duplicates keyboard scrolling the viewport already provides, so it stays out of the Tab sequence.
ScrollArea::scrollbar
View sourcepub fn scrollbar(self, state: &ScrollAreaState, orientation: ScrollAreaOrientation) -> ElementCreate the unstyled scrollbar part. Use [`Self::scrollbar_with`] to supply an existing element.
ScrollArea::thumb_with
View sourcepub fn thumb_with(self, orientation: ScrollAreaOrientation, thumb: Element) -> ElementDecorate one application-owned scrollbar thumb. The thumb carries the captured pointer drag. Attach a [`crate::ViewContext::pointer_listener`] registered for [`Self::thumb_id`] and forward the event to [`ScrollAreaState::apply_thumb_pointer`] with the track length the caller laid out.
ScrollArea::thumb
View sourcepub fn thumb(self, orientation: ScrollAreaOrientation) -> ElementCreate the unstyled thumb part. Use [`Self::thumb_with`] to supply an existing element.
ScrollArea::positioned_thumb_with
View sourcepub fn positioned_thumb_with( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, track_length: f32, thumb: Element, ) -> ElementDecorate and position one application-owned scrollbar thumb inside its scrollbar. This is [`Self::thumb_with`] plus the structural geometry a draggable thumb needs: the thumb is absolutely positioned along the scrollbar's axis at [`ScrollAreaState::thumb_offset`] with [`ScrollAreaState::thumb_length`], so it follows the offset without the application re-deriving either value. Cross-axis size and every visual property stay application-owned.
ScrollArea::positioned_thumb
View sourcepub fn positioned_thumb( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, track_length: f32, ) -> ElementCreate the unstyled positioned thumb part. Use [`Self::positioned_thumb_with`] to supply an existing element.
ScrollArea::corner_with
View sourcepub fn corner_with(self, corner: Element) -> ElementDecorate the application-owned corner between a horizontal and a vertical scrollbar.
ScrollArea::corner
View sourcepub fn corner(self) -> ElementCreate the unstyled corner part. Use [`Self::corner_with`] to supply an existing element.
