You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,9 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
16
16
-`MouseMove` events bubble up from widgets. `App` and `Screen` receive `MouseMove` events even if there's no Widget under the cursor. https://github.com/Textualize/textual/issues/2905
17
17
18
18
### Added
19
-
- Added an interface for replacing prompt of an individual option in an `OptionList`https://github.com/Textualize/textual/issues/2603
19
+
- Added an interface for replacing prompt of an individual option in an `OptionList`https://github.com/Textualize/textual/issues/2603
Copy file name to clipboardExpand all lines: docs/guide/widgets.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,47 @@ Let's use markup links in the hello example so that the greeting becomes a link
142
142
If you run this example you will see that the greeting has been underlined, which indicates it is clickable. If you click on the greeting it will run the `next_word` action which updates the next word.
143
143
144
144
145
+
## Border titles
146
+
147
+
Every widget has a [`border_title`][textual.widgets.Widget.border_title] and [`border_subtitle`][textual.widgets.Widget.border_subtitle] attribute.
148
+
Setting `border_title` will display text within the top border, and setting `border_subtitle` will display text within the bottom border.
149
+
150
+
!!! note
151
+
152
+
Border titles will only display if the widget has a [border](../styles/border.md) enabled.
153
+
154
+
The default value for these attributes is empty string, which disables the title.
155
+
You can change the default value for the title attributes with the [`BORDER_TITLE`][textual.widget.Widget.BORDER_TITLE] and [`BORDER_SUBTITLE`][textual.widget.Widget.BORDER_SUBTITLE] class variables.
156
+
157
+
Let's demonstrate setting a title, both as a class variable and a instance variable:
158
+
159
+
160
+
=== "hello06.py"
161
+
162
+
```python title="hello06.py" hl_lines="26 30"
163
+
--8<-- "docs/examples/guide/widgets/hello06.py"
164
+
```
165
+
166
+
1. Setting the default for the `title` attribute via class variable.
Note that titles are limited to a single line of text.
181
+
If the supplied text is too long to fit within the widget, it will be cropped (and an ellipsis added).
182
+
183
+
There are a number of styles that influence how titles are displayed (color and alignment).
184
+
See the [style reference](../styles/index.md) for details.
185
+
145
186
## Rich renderables
146
187
147
188
In previous examples we've set strings as content for Widgets. You can also use special objects called [renderables](https://rich.readthedocs.io/en/latest/protocol.html) for advanced visuals. You can use any renderable defined in [Rich](https://github.com/Textualize/rich) or third party libraries.
0 commit comments