Scroll
A scroll area, vertical, or horizontal after flex_row. Overflow is clipped and gets a draggable scrollbar.
ui.scrollBasic
ui.scroll().flex_row().w_fill().gap(8).py(4).children(|ui| { for i in 0..20 { ui.button(format_args!("Item {i}")).small(); }});Vertical
ui.scroll().w_fill().h(96).p(8).gap(4).bordered().rounded_md().children(|ui| { for i in 1..=20 { ui.text(format_args!("Line {i}")).text_sm(); }});API reference
| Setting | Description |
|---|---|
.style(style: Style) | Replaces the whole style. Later methods adjust it. |
.rounded_sm() | The theme's radius_sm. |
.rounded_md() | The theme's control radius. |
.rounded_lg() | The theme's radius_lg. |
.rounded_full() | Fully rounded ends. |
.bordered() | A 1 logical pixel border in the theme's border color. |
.bg_muted() | Fills with the theme's muted color, for quiet areas. |
.bg_surface() | Fills with the theme's surface color, as cards and popups do. |
.shadow_sm() | A small theme-colored shadow. |
.shadow_md() | A medium theme-colored shadow, as on cards. |
.shadow_lg() | A large theme-colored shadow, as on popovers and dialogs. |
.text_color(color: Color) | The color of text and icons inside, unless they set their own. |
.muted() | Gives text and icons inside the muted_foreground color. |
.text_sm() | Gives text inside the theme's small font size. |
.text_size(size: impl Length) | The font size of text inside, in logical pixels. |
.disabled(disabled: bool) | Disables every widget inside when true: dimmed, no pointer or keyboard, skipped by Tab. |
.when(condition: bool, f: impl FnOnce(Self) | Applies f when condition is true. |
.when_some(value: Option<T>, f: impl FnOnce(Self, T) | Applies f to the value when there is one. |
.hover(f: impl FnOnce(Style) | The look while the pointer is over the container or a widget inside. f may change the background, border, radius, shadow, ring or opacity, eased over the theme's motion duration. Call it after the other style methods. Scroll areas and overlays ignore it. |
.active(f: impl FnOnce(Style) | The look while the primary button is held on the container or a widget inside, on top of hover. |
.focus_within(f: impl FnOnce(Style) | The look while a control inside has the keyboard focus. |
.children(f: impl FnOnce(&mut Ui<'a>) | Places the container with the children declared by f, and returns the result of f. |
.children_with_response(f: impl FnOnce(&mut Ui<'a>) | Like children, also returning the container's interaction result. It is hovered and pressed while the pointer is over it or a widget inside. A click on a widget inside belongs to that widget. |
.w(width: impl Into<Sizing>) | Sets the width rule. |
.h(height: impl Into<Sizing>) | Sets the height rule. |
.size(width: impl Into<Sizing>, height: impl Into<Sizing>) | Sets the width and height rules. |
.w_fill() | Takes the remaining width (Sizing::FILL). |
.h_fill() | Takes the remaining height. |
.fill() | Takes the remaining width and height. |
.min_w(size: impl Length) | Sets the minimum width, which overrides the width rule and content. |
.max_w(size: impl Length) | Sets the maximum width, wrapping text to it. min_w wins. |
.min_h(size: impl Length) | Sets the minimum height, which overrides the height rule and content. |
.max_h(size: impl Length) | Sets the maximum height. min_h wins over it. |
.p(padding: impl Length) | Sets all padding. |
.px(padding: impl Length) | Sets the horizontal padding. |
.py(padding: impl Length) | Sets the vertical padding. |
.pt(padding: impl Length) | Sets the top padding. |
.pr(padding: impl Length) | Sets the right padding. |
.pb(padding: impl Length) | Sets the bottom padding. |
.pl(padding: impl Length) | Sets the left padding. |
.padding(padding: Edges) | Sets each side's padding. |
.gap(gap: impl Length) | Sets the spacing between children and between wrapped lines. |
.justify_start() | Places children at the start (default). |
.justify_center() | Centers children along the layout direction. |
.justify_end() | Places children at the end. |
.justify_between() | Spreads free space between children (Align::Between). |
.justify_around() | Spreads free space around children (Align::Around). |
.justify_evenly() | Spreads free space evenly (Align::Evenly). |
.items_baseline() | Aligns text baselines in a row (Align::Baseline). |
.self_start() | Aligns itself to the start across the layout (top in a stack). |
.self_center() | Centers itself across the layout (vertically in a stack). |
.self_end() | Aligns itself to the end across the layout (bottom in a stack). |
.self_stretch() | Stretches itself across the layout (vertically in a stack) if its size there is not fixed. |
.justify_self_start() | Aligns itself left in a stack. Ignored elsewhere. |
.justify_self_center() | Centers itself horizontally in a stack. Ignored elsewhere. |
.justify_self_end() | Aligns itself right in a stack. Ignored elsewhere. |
.aspect_ratio(ratio: f32) | Sets the width to height ratio. |
.gap_x(gap: impl Length) | Sets the horizontal gap, overriding gap. |
.gap_y(gap: impl Length) | Sets the vertical gap, overriding gap. |
.layout_priority(priority: f32) | Sets the priority for keeping width when a row is too narrow. |
.col_span(columns: u32) | Spans columns columns of its grid. |
.offset(x: impl Length, y: impl Length) | Shifts the element right and down, or back with negative values. Nothing else moves. |
.items_start() | Aligns children to the start across the layout (default for columns). |
.items_center() | Centers children across the layout (default for rows). |
.items_end() | Aligns children to the end across the layout. |
.items_stretch() | Stretches children across the layout unless their size there is fixed. |
.center() | Centers children both ways. |
.flex_row() | Lays out horizontally. |
.flex_col() | Lays out vertically. |
.flex_wrap() | Wraps a full row. |
.bg(color: Color) | Sets the background color. |
.rounded(radius: impl Length) | Sets the corner radius. Above half the height, the ends are fully round. |
.border(width: impl Length, color: Color) | Sets a border drawn inside the edges. |
.overflow_hidden() | Clips children beyond the node's bounds. |
.shadow(blur: impl Length, offset: impl Length, color: Color) | Sets a shadow. |
.ring(width: impl Length, color: Color) | Sets the focus ring outside the border. |
.opacity(opacity: f32) | Sets the subtree opacity (0–1). |