Skip to content

Commit 88220b8

Browse files
committed
docs
1 parent 1e4ab38 commit 88220b8

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from textual.app import App
2+
from textual.containers import Horizontal, VerticalScroll
3+
from textual.widgets import Label
4+
5+
TEXT = """I must not fear.
6+
Fear is the mind-killer.
7+
Fear is the little-death that brings total obliteration.
8+
I will face my fear.
9+
I will permit it to pass over me and through me.
10+
And when it has gone past, I will turn the inner eye to see its path.
11+
Where the fear has gone there will be nothing. Only I will remain.
12+
"""
13+
14+
15+
class ScrollbarApp(App):
16+
CSS_PATH = "scrollbar_visibility.tcss"
17+
18+
def compose(self):
19+
yield Horizontal(
20+
VerticalScroll(Label(TEXT * 10), classes="left"),
21+
VerticalScroll(Label(TEXT * 10), classes="right"),
22+
)
23+
24+
25+
if __name__ == "__main__":
26+
app = ScrollbarApp()
27+
app.run()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
VerticalScroll {
2+
width: 1fr;
3+
}
4+
5+
.left {
6+
scrollbar-visibility: visible; # The default
7+
}
8+
9+
.right {
10+
scrollbar-visibility: hidden;
11+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Scrollbar-visibility
2+
3+
The `scrollbar-visibility` is used to show or hide scrollbars.
4+
5+
If scrollbars are hidden, the user may still scroll the container using the mouse wheel / keys / and gestures, but
6+
there will be no scrollbars shown.
7+
8+
## Syntax
9+
10+
--8<-- "docs/snippets/syntax_block_start.md"
11+
scrollbar-visibility: hidden | visible;
12+
--8<-- "docs/snippets/syntax_block_end.md"
13+
14+
15+
### Values
16+
17+
| Value | Description |
18+
| ------------------- | ---------------------------------------------------- |
19+
| `hidden` | The widget's scrollbars will be hidden. |
20+
| `visible` (default) | The widget's scrollbars will be displayed as normal. |
21+
22+
23+
## Examples
24+
25+
The following example contains two containers with the same text.
26+
The container on the right has its scrollbar hidden.
27+
28+
=== "Output"
29+
30+
```{.textual path="docs/examples/styles/scrollbar_visibility.py"}
31+
```
32+
33+
=== "scrollbar_visibility.py"
34+
35+
```py
36+
--8<-- "docs/examples/styles/scrollbar_visibility.py"
37+
```
38+
39+
=== "scrollbar_visibility.tcss"
40+
41+
```css
42+
--8<-- "docs/examples/styles/scrollbar_visibility.tcss"
43+
```
44+
45+
46+
## CSS
47+
48+
```css
49+
scrollbar-visibility: visible;
50+
scrollbar-visibility: hidden;
51+
```
52+
53+
54+
55+
## Python
56+
57+
```py
58+
widget.styles.scrollbar_visibility = "visible";
59+
widget.styles.scrollbar_visibility = "hidden";
60+
```

mkdocs-nav.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ nav:
136136
- "styles/scrollbar_colors/scrollbar_corner_color.md"
137137
- "styles/scrollbar_gutter.md"
138138
- "styles/scrollbar_size.md"
139+
- "styles/scrollbar_visibility.md"
139140
- "styles/text_align.md"
140141
- "styles/text_opacity.md"
141142
- "styles/text_overflow.md"

src/textual/widget.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3421,7 +3421,6 @@ def scroll_to_widget(
34213421
`True` if any scrolling has occurred in any descendant, otherwise `False`.
34223422
"""
34233423
# Grow the region by the margin so to keep the margin in view.
3424-
34253424
region = widget.virtual_region_with_margin
34263425
scrolled = False
34273426

0 commit comments

Comments
 (0)