github charmbracelet/lipgloss v0.6.0

latest releases: v0.13.0, v0.12.1, v0.12.0...
2 years ago

Vertical Alignment & Complete Colors

In this latest release of Lip Gloss, styles now support vertical alignment for all your vertical alignment needs! Additionally, CompleteColor and CompleteAdaptiveColor was introduced.

Align content in a Style vertically at the top, center, or bottom. To get started make a style with some Height and an AlignVertical property.

lipgloss.NewStyle().Height(5).AlignVertical(lipgloss.Center).Render("Hello, Center!")

or use the Align shorthand which sets both horizontal and vertical alignments:

lipgloss.NewStyle().Height(5).Align(lipgloss.Left, lipgloss.Bottom).Render("Hello, Center!")

image

New API:

Note, there are no breaking changes since if the Align shorthand will still accept 1 argument (variadic arguments) and will set only the horizontal alignment to maintain original functionality

  • Align(p ...Position)
  • AlignVertical(p Position)
  • AlignHorizontal(p Position)
  • GetAlignVertical() Position
  • GetAlignHorizontal() Position

Complete Colors

This revision introduces two new color types CompleteColor and CompleteAdaptiveColor. Not for the faint of heart, these types are for bypassing automatic color interpolation so you can specify exact colors for all color profiles:

cc := CompleteColor{
	TrueColor: "#6B51FF",
	ANSI256: "63",
	ANSI: "5",
}

cac := CompleteAdaptiveColor{
	Light: CompleteColor{
		TrueColor: "#FF51CE",
		ANSI256: "213",
		ANSI: "5",
	},
	Dark: CompleteColor{
		TrueColor: "#6B51FF",
		ANSI256: "63",
		ANSI: "5",
	},
}

New

Fixed

  • Protect against concurrent color profile access with a sync.RWMutex by @meowgorithm in #68
  • don't overwrite background when inheriting by @76creates in #69

New Contributors

Full Changelog: v0.5.0...v0.6.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.

Don't miss a new lipgloss release

NewReleases is sending notifications on new releases.