| 1 |
Panel |
| 2 |
===== |
| 3 |
|
| 4 |
To draw a border around text or other renderable, construct a :class:`~rich.panel.Panel` with the renderable as the first positional argument. Here's an example:: |
| 5 |
|
| 6 |
from rich import print |
| 7 |
from rich.panel import Panel |
| 8 |
print(Panel("Hello, [red]World!")) |
| 9 |
|
| 10 |
You can change the style of the panel by setting the ``box`` argument to the Panel constructor. See :ref:`appendix_box` for a list of available box styles. |
| 11 |
|
| 12 |
Panels will extend to the full width of the terminal. You can make panel *fit* the content by setting ``expand=False`` on the constructor, or by creating the Panel with :meth:`~rich.panel.Panel.fit`. For example:: |
| 13 |
|
| 14 |
from rich import print |
| 15 |
from rich.panel import Panel |
| 16 |
print(Panel.fit("Hello, [red]World!")) |
| 17 |
|
| 18 |
The Panel constructor accepts a ``title`` argument which will draw a title on the top of the panel, as well as a ``subtitle`` argument which will draw a subtitle on the bottom of the panel:: |
| 19 |
|
| 20 |
from rich import print |
| 21 |
from rich.panel import Panel |
| 22 |
print(Panel("Hello, [red]World!", title="Welcome", subtitle="Thank you")) |
| 23 |
|
| 24 |
See :class:`~rich.panel.Panel` for details how to customize Panels. |