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
This will make "Hello" bold, but the rest of the text will be non-bold.
88
80
89
-
You can use any number of tags, and they may overlap which combines their styles.
81
+
You can use any number of tags.
82
+
If tags overlap their styles are combined.
90
83
For instance, the following combines the bold and italic styles:
91
84
92
85
```
93
86
[bold]Bold [italic]Bold and italic[/italic][/bold]
94
87
```
95
88
89
+
Here's the output:
90
+
91
+
```{.textual path="docs/examples/guide/content/playground.py", type="[bold]Bold [italic]Bold and italic[/italic][/bold]" lines=15}
92
+
```
93
+
96
94
#### Auto-closing tags
97
95
98
96
A closing tag without any style information (i.e. `[/]`) is an *auto-closing* tag.
99
-
Auto-closing tags will close the last tag, regardless of it's style.
97
+
Auto-closing tags will close the last opened tag.
100
98
101
99
The following uses an auto-closing tag to end the bold style:
102
100
@@ -135,7 +133,8 @@ Styles can also be combined within the same tag, so `[bold italic]` produces tex
135
133
You can invert a style by preceding it with the word `not`.
136
134
This is useful if you have text with a given style, but you temporarily want to disable it.
137
135
138
-
For instance, the following markup starts with `[bold]` which makes the text bold until it reaches `[not bold]` which disables the bold style, until the corresponding `[/not bold]`.
136
+
For instance, the following starts with `[bold]`, which would normally make the rest of the text bold.
137
+
However, the `[not bold]` tag disables bold until the corresponding `[/not bold]` tag:
139
138
140
139
```
141
140
[bold]This is bold [not bold]This is not bold[/not bold] This is bold.
@@ -166,23 +165,28 @@ You can also any of the [named colors](/css_types/color).
166
165
167
166
Colors may also include an *alpha* component, which makes the color fade in to the background.
168
167
For instance, if we specify the color with `rgba(...)`, then we can add an alpha component between 0 and 1.
169
-
An alpha of zero is fully transparent (and therefore invisible). An alpha of 1 is fully opaque, and equivalent to a color without an alpha component.
170
-
A value between 0 and 1 results in a faded color.
168
+
An alpha of 0 is fully transparent (and therefore invisible). An alpha of 1 is fully opaque, and equivalent to a color without an alpha component.
169
+
A value between 0 and 1 results in a faded color.
171
170
172
171
In the following example we have an alpha of 0.5, which will produce a color half way between the background and solid green:
173
172
174
173
```
175
174
[rgba(0, 255, 0, 0.5)]Faded green (and probably hard to read)[/]
176
175
```
177
176
178
-
!!! tip
177
+
Here's the output:
178
+
179
+
```{.textual path="docs/examples/guide/content/playground.py", type="[rgba(0, 255, 0, 0.5)]Faded green (and probably hard to read)[/]" lines=15}
180
+
```
181
+
182
+
!!! warning
179
183
180
184
Be careful when using colors with an alpha component. Text that is blended too much with the background may become hard to read.
181
185
182
186
183
187
#### Auto colors
184
188
185
-
You can specify a color as "auto", which is a special value that tells Textual to pick either white or black text -- whichever has the best contrast.
189
+
You can also specify a color as "auto", which is a special value that tells Textual to pick either white or black text -- whichever has the best contrast.
186
190
187
191
For example, the following will produce either white or black text (I haven't checked) on a sienna background:
188
192
@@ -193,7 +197,7 @@ For example, the following will produce either white or black text (I haven't ch
193
197
194
198
#### Opacity
195
199
196
-
While you can set the opacity in the color itself, you can also add a percentage which will modify the alpha component of the previous color.
200
+
While you can set the opacity in the color itself by adding an alpha component to the color, you can also modify the alpha of the previous color with a percentage.
197
201
198
202
For example, the addition of `50%` will result in a color half way between the background and "red":
199
203
@@ -220,6 +224,7 @@ Here's an example that tints the background with 20% red:
220
224
[on #ff0000 20%]The background has a red tint.[/]
221
225
```
222
226
227
+
Here's the output:
223
228
224
229
```{.textual path="docs/examples/guide/content/playground.py" lines=15 type="[on #ff0000 20%]The background has a red tint.[/]"]}
225
230
```
@@ -243,14 +248,16 @@ The following displays text in the 'warning' style on a muted 'warning' backgrou
243
248
[$warning on $warning-muted]This is a warning![/]
244
249
```
245
250
251
+
Here's the result of that markup:
252
+
246
253
```{.textual path="docs/examples/guide/content/playground.py" lines=15 type="[$warning on $warning-muted]This is a warning![/]"]}
247
254
```
248
255
249
256
### Links
250
257
251
258
Styles may contain links which will create clickable links that launch your web browser, if supported by your terminal.
252
259
253
-
To create a link add `link=` followed by your link in quotes.
260
+
To create a link add `link=` followed by your link in quotes (single or double).
254
261
For instance, the following create a clickable link:
255
262
256
263
```
@@ -262,6 +269,7 @@ This will produce the following output:
262
269
263
270
264
271
272
+
265
273
## Content class
266
274
267
275
Under the hood, Textual will convert markup into a [Content][textual.content.Content] instance.
0 commit comments