Repository navigation
Description
Summary
TextArea::auto_grow and TextArea::max_height create an internal viewport keyed "scroll" that clips overflowing text, but there is no way to attach a kit scroll bar to it. As a result, a TextArea that scrolls internally never shows a scroll bar.
Why
El::scroll_bar_styled wraps the element it is called on. Applying it to the enclosing layout element does not work, because that element does not overflow: TextArea caps and scrolls its own internal viewport.
For example, this does not show a scroll bar:
let composer = col()
.padding(16.0)
.scroll(ScrollSpec { stick_bottom: true })
.child(
TextArea::new(&state.draft)
.auto_grow(2, 6)
.build(&k),
);
// The bar is attached to the outer viewport, which never overflows.
col().child(composer.scroll_bar_styled(ScrollBarStyle::from_kit(&k)));The viewport that actually overflows is the one created inside TextArea::build by rune::auto_grow(field, min_rows, max_rows), keyed "scroll". It currently has no way to opt into a scroll bar.
Proposed API
Mirror El::scroll_bar and El::scroll_bar_styled on TextArea:
TextArea::new(&state.draft)
.auto_grow(2, 6)
.scroll_bar_styled(ScrollBarStyle::from_kit(&k))
.build(&k);Implementation sketch
Add option fields to TextArea, then wrap the internal viewport in build if enabled:
pub struct TextArea {
// ...
scroll_bar: Option<bool>,
scroll_bar_style: Option<ScrollBarStyle>,
// ...
}
impl TextArea {
/// Enable or disable a visible scroll bar. Use the `Kit` supplied during build if enabled.
/// Use `scroll_bar_styled` to enable the scroll bar with a passed in style rather than generated.
pub fn scroll_bar(mut self, on: bool) -> Self {
self.scroll_bar = if on { Some(true) } else { None };
self.scroll_bar_style = None;
self
}
/// Draw a scroll bar on the field's internal scroll viewport using the supplied style.
/// Use `scroll_bar` to generate the scroll bar styling during `build` instead of supplying one.
pub fn scroll_bar_styled(mut self, style: ScrollBarStyle) -> Self {
self.scroll_bar = Some(true);
self.scroll_bar_style = Some(style);
self
}
pub fn build(self, k: &Kit) -> El {
// ...
let viewport = rune::auto_grow(field, min_rows, max_rows);
let viewport = match self.scroll_bar {
Some(true) => viewport.scroll_bar_styled(style.unwrap_or(ScrollBarStyle::from_kit(&k))),
_ => viewport,
};
// ...
}
}The same wrapping should apply to the viewport created by the max_height branch.
Should also have a clean way to turn the scroll bar on and off and use either a supplied style or one generated from the Kit during build.
Wanted to note it for completeness but I don't think the ScrollBar trait impl is needed on TextArea (impl ScrollBar for TextArea). The underlying El that TextArea::build produces will implement it already. But the function names match for consistency.
Activity
Hona commentedon Nov 24, 2026
Implemented on
devin #1967 (0c85015b7).TextArea::scroll_bar(bool)andTextArea::scroll_bar_styled(ScrollBarStyle)attach a kit scroll bar to the internal"scroll"viewport created byauto_growormax_height(a no-op when neither is set; off by default), followingrune::system_scroll_bars()and keeping focus and caret intact while dragging the thumb. The API followsTree::scroll_bar/Tree::scroll_bar_styled(crates/rune-kit/src/tree/view.rs) andScrollBar(crates/rune-kit/src/scroll_bar.rs), matching your proposed builder names (with a single internal enum soscroll_bar(false)clears an earlier style). Seeexamples/kit-galleryscenerune-textarea--composer.Tested with headless
Runtimeintegration and accessibility tests incrates/rune-kit/tests/integration/text_area_chrome.rsandcrates/rune-kit/tests/a11y/controls.rs(coveringauto_grow,max_height, custom styles, sibling independence, RTL, anda11y_hidden) on Windows and macOS, plus Linuxcargo check --tests,kit-gallerybuild tests, andwasm32checks. Not visually inspected in a live desktop window or on physical devices. If anything is missing for your use case, please let us know.