or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

console.mdcontainers.mdindex.mdinteractive.mdlayout.mdmarkdown.mdprogress.mdsyntax.mdtables.mdtext-styling.mdutilities.md

containers.mddocs/

0

# Panels and Containers

1

2

Panels, rules, columns, and other container components for organizing content. Rich provides various container components for structuring and organizing terminal output.

3

4

## Capabilities

5

6

### Panel Class

7

8

Decorative panels with borders and titles.

9

10

```python { .api }

11

class Panel:

12

"""

13

Panel with border and optional title.

14

15

Args:

16

renderable: Content to display in panel

17

box: Box style for borders

18

safe_box: Use safe box characters

19

expand: Expand to fit available width

20

style: Panel style

21

border_style: Border style

22

width: Fixed width or None for auto

23

height: Fixed height or None for auto

24

padding: Internal padding

25

highlight: Enable content highlighting

26

title: Panel title

27

title_align: Title alignment

28

subtitle: Panel subtitle

29

subtitle_align: Subtitle alignment

30

"""

31

def __init__(

32

self,

33

renderable: RenderableType,

34

box: Box = box.ROUNDED,

35

*,

36

safe_box: Optional[bool] = None,

37

expand: bool = True,

38

style: StyleType = "none",

39

border_style: StyleType = "none",

40

width: Optional[int] = None,

41

height: Optional[int] = None,

42

padding: PaddingDimensions = (0, 1),

43

highlight: bool = False,

44

title: Optional[TextType] = None,

45

title_align: AlignMethod = "center",

46

subtitle: Optional[TextType] = None,

47

subtitle_align: AlignMethod = "center",

48

): ...

49

50

@classmethod

51

def fit(

52

cls,

53

renderable: RenderableType,

54

box: Box = box.ROUNDED,

55

*,

56

safe_box: Optional[bool] = None,

57

style: StyleType = "none",

58

border_style: StyleType = "none",

59

padding: PaddingDimensions = (0, 1),

60

title: Optional[TextType] = None,

61

title_align: AlignMethod = "center",

62

) -> "Panel":

63

"""Create a panel that fits content exactly."""

64

65

class Rule:

66

"""Horizontal rule with optional title."""

67

def __init__(

68

self,

69

title: TextType = "",

70

*,

71

characters: str = "─",

72

style: StyleType = "rule.line",

73

end: str = "\n",

74

align: AlignMethod = "center",

75

): ...

76

77

class Columns:

78

"""Multi-column layout for renderables."""

79

def __init__(

80

self,

81

renderables: Optional[Iterable[RenderableType]] = None,

82

width: Optional[int] = None,

83

padding: PaddingDimensions = (0, 1),

84

expand: bool = False,

85

equal: bool = False,

86

column_first: bool = False,

87

right_to_left: bool = False,

88

align: AlignMethod = "left",

89

title: Optional[TextType] = None,

90

): ...

91

```

92

93

**Usage Examples:**

94

95

```python

96

from rich.console import Console

97

from rich.panel import Panel

98

from rich.rule import Rule

99

from rich.columns import Columns

100

101

console = Console()

102

103

# Basic panel

104

panel = Panel("Hello, World!", title="Greeting")

105

console.print(panel)

106

107

# Rule

108

console.print(Rule("Section 1"))

109

console.print("Content here")

110

console.print(Rule())

111

112

# Columns

113

columns = Columns([

114

Panel("Column 1"),

115

Panel("Column 2"),

116

Panel("Column 3")

117

])

118

console.print(columns)

119

```