This section describes container options that specify its style or look.
Borders for containers
Containers don't have any borders by default, use one of the following options to instruct Termdash to draw a border around a container.
/images/container-api/border_styles.png
The following code shows two containers with different border styles as shown above. The right container has the keyboard focus so its border is highlighted.
t, err := tcell.New()
if err != nil {
panic(err)
}
defer t.Close()
c, err := container.New(
t,
container.SplitVertical(
container.Left(
container.Border(linestyle.Light),
),
container.Right(
container.Border(linestyle.Double),
),
),
)
if err != nil {
return fmt.Errorf("container.New => %v", err)
}
container.Border:
The container.Border option is used to enable the border and specify its line style. Refer to the Linestyle API for the available line styles.
container.BorderColor:
The container.BorderColor option sets the color of the border. This option takes no effect when the container has no border.
container.FocusedColor:
The container.FocusedColor option sets the color of the border when the container is focused. This option takes no effect when the container has no border.
Titles for containers
Containers that have a border can also have a text title displayed in the border. The title isn't visible on a container without border.
/images/container-api/border_title.png
The following code shows a container with a title in the border that is aligned to the right.
t, err := tcell.New()
if err != nil {
panic(err)
}
defer t.Close()
c, err := container.New(
t,
container.Border(linestyle.Light),
container.BorderTitle("hello world"),
container.BorderTitleAlignRight(),
)
if err != nil {
return fmt.Errorf("container.New => %v", err)
}
container.BorderTitle:
The container.BorderTitle option sets the title to display on the container. The title is displayed above the container and aligned according to the following alignment options.
container.BorderTitleAlignLeft:
The container.BorderTitleAlignLeft option indicates that the container title should be aligned at the top left corner.
container.BorderTitleAlignCenter:
The container.BorderTitleAlignCenter option indicates that the container title should be aligned at the top and center above the container.
container.BorderTitleAlignRight:
The container.BorderTitleAlignRight option indicates that the container title should be aligned at the top right corner.
Help
API Documentation
Terminal layer
Infrastructure layer
Container layer
Widgets layer
Tips and tricks
See a typo, something missing or outright wrong? Feel free to edit the Wiki pages directly, alternatively talk to us.