Terminal flexbox layout library built on Lip Gloss v2.
go get github.com/gausszhou/bubblefleximport "github.com/gausszhou/bubbleflex"flex.New(flex.Row).Gap(1).Join("Alice", "Bob", "Charlie")
// => Alice Bob Charlieflex.New(flex.Column).Gap(1).Join("a", "b", "c")
// =>
// a
//
// b
//
// cflex.New(flex.Row).
JustifyContent(flex.SpaceBetween).
Width(80).
Join(red("ERROR"), green("OK"), blue("INFO"))[flex-start]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯
[flex-end]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯
[center]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯
[space-between]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯
[space-around]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯
[space-evenly]
╭─────────────────────────────────────────────────────╮
│ A B C │
╰─────────────────────────────────────────────────────╯| Name | CSS equivalent | Description |
|---|---|---|
flex.Row |
flex-direction: row |
Horizontal layout |
flex.Column |
flex-direction: column |
Vertical layout |
flex.Start |
justify-content: flex-start |
Align to start |
flex.End |
justify-content: flex-end |
Align to end |
flex.Center |
justify-content: center |
Center |
flex.SpaceBetween |
justify-content: space-between |
Distribute space between items |
flex.SpaceAround |
justify-content: space-around |
Distribute space around items |
flex.SpaceEvenly |
justify-content: space-evenly |
Distribute space evenly |
| Method | Description |
|---|---|
New(d Direction) *Flex |
Create a flex layout |
JustifyContent(a Align) *Flex |
Set main-axis alignment |
Gap(n int) *Flex |
Set spacing between items |
Width(n int) *Flex |
Set container width (Row) |
Height(n int) *Flex |
Set container height (Column) |
Join(items ...string) string |
Render the layout |
Apache 2.0