Files
textual/docs/styles/min_width.md
Rodrigo Girão Serrão 196d430582 Style all Textual CSS as 'sass'
Textual CSS is better highlighted in SASS code blocks because the SASS parser seems to be more lenient.
2023-01-09 11:20:04 +00:00

57 lines
1.3 KiB
Markdown

# Min-width
The `min-width` rule sets a minimum width for a widget.
## Syntax
--8<-- "docs/snippets/syntax_block_start.md"
min-width: <a href="../../css_types/scalar">&lt;scalar&gt;</a>;
--8<-- "docs/snippets/syntax_block_end.md"
The `min-width` rule accepts a [`<scalar>`](../../css_types/scalar) that defines a lower bound for the [`width`](./width) of a widget.
That is, the width of a widget is never allowed to be under `min-width`.
## Example
The example below shows some placeholders with their width set to `50%`.
Then, we set `min-width` individually on each placeholder.
=== "Output"
```{.textual path="docs/examples/styles/min_width.py"}
```
=== "min_width.py"
```py
--8<-- "docs/examples/styles/min_width.py"
```
=== "min_width.css"
```sass hl_lines="13"
--8<-- "docs/examples/styles/min_width.css"
```
1. This won't affect the placeholder because its width is larger than the minimum width.
## CSS
```sass
/* Set the minimum width to 10 rows */
min-width: 10;
/* Set the minimum width to 25% of the viewport width */
min-width: 25vh;
```
## Python
```python
# Set the minimum width to 10 rows
widget.styles.min_width = 10
# Set the minimum width to 25% of the viewport width
widget.styles.min_width = "25vh"
```