mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
more docs
This commit is contained in:
48
docs/styles/visibility.md
Normal file
48
docs/styles/visibility.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Visibility
|
||||
|
||||
The `visibility` rule may be used to make a widget invisible while still reserving spacing for it. The default value is `"visible"` which will cause the Widget to be displayed as normal. Setting the value to `"hidden"` will cause the Widget to be removed from the screen.
|
||||
|
||||
## Example
|
||||
|
||||
Note that the second widget is hidden, while leaving a space where it would have been rendered.
|
||||
|
||||
=== "visibility.py"
|
||||
|
||||
```python
|
||||
--8<-- "docs/examples/styles/visibility.py"
|
||||
```
|
||||
|
||||
=== "Output"
|
||||
|
||||
```{.textual path="docs/examples/styles/visibility.py"}
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```sass
|
||||
/* Widget is on screen */
|
||||
visibility: visible;
|
||||
|
||||
/* Widget is not on the screen */
|
||||
visibility: hidden;
|
||||
```
|
||||
|
||||
## Python
|
||||
|
||||
```python
|
||||
# Widget is invisible
|
||||
self.styles.visibility = "hidden"
|
||||
|
||||
# Widget is visible
|
||||
self.styles.visibility = "visible"
|
||||
```
|
||||
|
||||
There is also a shortcut to set a Widget's visibility. The `visible` property on `Widget` may be set to `True` or `False`.
|
||||
|
||||
```python
|
||||
# Make a widget invisible
|
||||
widget.visible = False
|
||||
|
||||
# Make the widget visible again
|
||||
widget.visible = True
|
||||
```
|
||||
Reference in New Issue
Block a user