Skip to content

gausszhou/bubbleflex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bubbleflex

Terminal flexbox layout library built on Lip Gloss v2.

go get github.com/gausszhou/bubbleflex

Quick start

import "github.com/gausszhou/bubbleflex"

Row layout

flex.New(flex.Row).Gap(1).Join("Alice", "Bob", "Charlie")
// => Alice Bob Charlie

Column layout

flex.New(flex.Column).Gap(1).Join("a", "b", "c")
// =>
// a
//
// b
//
// c

Alignment with container width

flex.New(flex.Row).
    JustifyContent(flex.SpaceBetween).
    Width(80).
    Join(red("ERROR"), green("OK"), blue("INFO"))

Examples

[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            │
╰─────────────────────────────────────────────────────╯

API

Constants

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

Methods

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

License

Apache 2.0

About

一个基于 lipgloss 的 Flexbox 布局库; A flexbox layout library built on Lip Gloss.

Resources

License

Stars

Watchers

Forks

Contributors