1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//! Theme-aware scrollport using native CSS scrollbars.
use Div;
use *;
use component_doc;
use inject_style;
use inline_style_sheet_values;
use scroll_area_styles;
/// Scrollable region with Orbital-themed native scrollbars.
///
/// Styled **native scrolling** — not virtualization. Uses `overflow: auto` and CSS `scrollbar-*` / `::-webkit-scrollbar` rules so thumbs track design tokens (light/dark). Use in shell [`Layout`](crate::Layout) columns, [`Navigation`](crate::Navigation) bodies, and custom panels.
///
/// # When to use
///
/// - Fixed-height regions with overflowing content (sidebar nav, main columns, panels) - Any scrollport that should match Orbital theme rather than default OS chrome colors - Horizontal overflow when `horizontal=true` (wide toolbars, carousels)
///
/// # Usage
///
/// 1. Set `style` height (or width for horizontal) on `ScrollArea` so the scrollport has bounds. 2. Put overflowing content inside the default slot. 3. Set `show_scrollbar=false` to hide scrollbar chrome while keeping wheel/touch scroll. 4. Adjust `size` for scrollbar thumb/track thickness in pixels (default `8`) — not viewport size.
///
/// # Best Practices
///
/// ## Do's
///
/// * Give the scrollport explicit `height: 100%` or `flex: 1; min-height: 0` in flex layouts * Use `ScrollArea` in [`Layout`](crate::Layout) and [`Navigation`](crate::Navigation) for consistent scrollbar styling
///
/// ## Don'ts
///
/// * Do not nest `ScrollArea` inside another scrollport without clearing overflow on the parent
///
/// # Examples
///
/// ## Default vertical scroll
/// Vertical scrollport with themed thumbs on a bounded demo frame.
/// <!-- default -->
/// <!-- preview -->
/// ```rust
/// use crate::ScrollArea;
/// view! {
/// <div data-testid="scroll-area-default" style="width: 100%; max-width: 560px;">
/// <ScrollArea style="display: block; width: 100%; height: 280px; box-sizing: border-box; border: 1px solid var(--orb-color-border-default); padding: 16px; background: var(--orb-color-surface-subtle);">
/// <div style="display: flex; flex-direction: column; gap: 12px; min-height: 520px;">
/// <p>"Content is taller than the 280px scrollport."</p>
/// <p>"Scroll with wheel, trackpad, or drag the themed scrollbar thumb."</p>
/// {(0..12)
/// .map(|i| view! { <p>{format!("Line {i} — extra content to ensure vertical overflow.")}</p> })
/// .collect_view()}
/// </div>
/// </ScrollArea>
/// </div>
/// }
/// ```
///
/// ## Scrollbar visibility
/// Side-by-side: themed thumbs (default) versus hidden chrome with wheel scroll only.
/// <!-- preview -->
/// ```rust
/// use crate::{Body1Strong, Flex, FlexGap, ScrollArea};
/// const FRAME: &str = "display: block; width: 100%; height: 240px; box-sizing: border-box; border: 1px solid var(--orb-color-border-default); padding: 12px; background: var(--orb-color-surface-subtle);";
/// view! {
/// <div style="width: 100%; max-width: 560px;">
/// <Flex vertical=true gap=FlexGap::Large>
/// <div data-testid="scroll-area-visible" style="width: 100%;">
/// <Body1Strong block=true style="margin: 0 0 8px;">"Thumbs visible"</Body1Strong>
/// <ScrollArea style=FRAME>
/// <div style="min-height: 480px; display: flex; flex-direction: column; gap: 8px;">
/// {(0..10)
/// .map(|i| view! { <p style="margin: 0;">{format!("Visible scrollbar line {i}")}</p> })
/// .collect_view()}
/// </div>
/// </ScrollArea>
/// </div>
/// <div data-testid="scroll-area-hidden" style="width: 100%;">
/// <Body1Strong block=true style="margin: 0 0 8px;">"Thumbs hidden"</Body1Strong>
/// <ScrollArea show_scrollbar=false style=FRAME>
/// <div style="min-height: 480px; display: flex; flex-direction: column; gap: 8px;">
/// {(0..10)
/// .map(|i| view! { <p style="margin: 0;">{format!("Hidden scrollbar line {i}")}</p> })
/// .collect_view()}
/// </div>
/// </ScrollArea>
/// </div>
/// </Flex>
/// </div>
/// }
/// ```
///
/// ## Horizontal scroll
/// Bounded width with wide inner content; horizontal thumb uses the same theme tokens.
/// <!-- preview -->
/// ```rust
/// use crate::ScrollArea;
/// view! {
/// <div data-testid="scroll-area-horizontal" style="width: 100%; max-width: 560px;">
/// <ScrollArea
/// horizontal=true
/// style="display: block; width: 100%; height: 200px; box-sizing: border-box; border: 1px solid var(--orb-color-border-default); padding: 12px; background: var(--orb-color-surface-subtle);"
/// >
/// <div style="width: 900px; padding: 8px; white-space: nowrap;">
/// "Wide content that scrolls horizontally — drag or shift+wheel to move along the row."
/// </div>
/// </ScrollArea>
/// </div>
/// }
/// ```
]
node_ref: ,
/// Optional `data-testid` for the scrollport root (not forwarded to the injected `<style>` tag).
scroll_testid: ,
/// Optional `data-column-order` for consumers that track column layout on the scrollport.
scroll_data_column_order: ,
/// Scrollable content inside the themed scrollbar chrome.
children: Children,
)