Skip to content

Add Style#to_h to read a style's settings - #11

Merged
marcoroth merged 1 commit into
mainfrom
style-to-h
Nov 18, 2026
Merged

marcoroth merged 1 commit into
mainfrom
style-to-h

Conversation

@marcoroth

@marcoroth marcoroth commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

This pull request adds Lipgloss::Style#to_h, which returns the properties set on a style as a Hash.

Lip Gloss styles live on the Go side and Ruby only holds a handle, so there was no way to read a style back as data. Libraries that hand styles to another Go library, such as bloom bindings built against Lip Gloss v2, need the settings themselves rather than the rendered output.

style = Lipgloss::Style.new
  .bold(true)
  .foreground("#7aa2f7")
  .padding(0, 1)
  .border(:rounded)
  .border_foreground("63")
style.to_h
# => {
#   bold: true,
#   foreground: "#7aa2f7",
#   padding: [0, 1, 0, 1],
#   border: { top: "─", bottom: "─", left: "│", right: "│", top_left: "╭", ... },
#   border_sides: [true, true, true, true],
#   border_foreground: ["63", "63", "63", "63"]
# }

Only properties that are set are included, so Lipgloss::Style.new.to_h is {}.

@marcoroth
marcoroth merged commit bc939a0 into main Nov 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant