Files
textual/docs/widgets/rule.md
TomJGooding 06b6426750 feat: add rule widget (#3209)
* feat: add rule widget

* add star to init

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* remove unnecessary validations

* update rule styles

* add tests for invalid rules

* add minimum heights and widths

* tidy up examples

* remove old example

* move examples styling to tcss

* modify examples to fit docs screenshots

* add docs first draft

* add snapshot tests

* add rule to widget gallery

* make non-widget rule classes available

* tentatively update changelog

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
Co-authored-by: Will McGugan <willmcgugan@gmail.com>
2023-09-04 17:57:10 +01:00

1.5 KiB

Rule

A rule widget to separate content, similar to a <hr> HTML tag.

  • Focusable
  • Container

Examples

Horizontal Rule

The default orientation of a rule is horizontal.

The example below shows horizontal rules with all the available line styles.

=== "Output"

```{.textual path="docs/examples/widgets/horizontal_rules.py"}
```

=== "horizontal_rules.py"

```python
--8<-- "docs/examples/widgets/horizontal_rules.py"
```

=== "horizontal_rules.tcss"

```sass
--8<-- "docs/examples/widgets/horizontal_rules.tcss"
```

Vertical Rule

The example below shows vertical rules with all the available line styles.

=== "Output"

```{.textual path="docs/examples/widgets/vertical_rules.py"}
```

=== "vertical_rules.py"

```python
--8<-- "docs/examples/widgets/vertical_rules.py"
```

=== "vertical_rules.tcss"

```sass
--8<-- "docs/examples/widgets/vertical_rules.tcss"
```

Reactive Attributes

Name Type Default Description
orientation RuleOrientation "horizontal" The orientation of the rule.
line_style LineStyle "solid" The line style of the rule.

Messages

This widget sends no messages.


::: textual.widgets.Rule options: heading_level: 2

::: textual.widgets.rule options: show_root_heading: true show_root_toc_entry: true