@@ -29,6 +29,8 @@ func (s *Style) set(key propKey, value any) {
29 s.paddingBottom = max(0, value.(int))
29 s.paddingBottom = max(0, value.(int))
30 case paddingLeftKey:
30 case paddingLeftKey:
31 s.paddingLeft = max(0, value.(int))
31 s.paddingLeft = max(0, value.(int))
33+ s.paddingChar = value.(rune)
32 case marginTopKey:
34 case marginTopKey:
33 s.marginTop = max(0, value.(int))
35 s.marginTop = max(0, value.(int))
34 case marginRightKey:
36 case marginRightKey:
@@ -39,6 +41,8 @@ func (s *Style) set(key propKey, value any) {
39 s.marginLeft = max(0, value.(int))
41 s.marginLeft = max(0, value.(int))
40 case marginBackgroundKey:
42 case marginBackgroundKey:
41 s.marginBgColor = colorOrNil(value)
43 s.marginBgColor = colorOrNil(value)
45+ s.marginChar = value.(rune)
42 case borderStyleKey:
46 case borderStyleKey:
43 s.borderStyle = value.(Border)
47 s.borderStyle = value.(Border)
44 case borderTopForegroundKey:
48 case borderTopForegroundKey:
@@ -111,6 +115,8 @@ func (s *Style) setFrom(key propKey, i Style) {
111 s.set(paddingBottomKey, i.paddingBottom)
115 s.set(paddingBottomKey, i.paddingBottom)
112 case paddingLeftKey:
116 case paddingLeftKey:
113 s.set(paddingLeftKey, i.paddingLeft)
117 s.set(paddingLeftKey, i.paddingLeft)
118+ case paddingCharKey:
119+ s.set(paddingCharKey, i.paddingChar)
114 case marginTopKey:
120 case marginTopKey:
115 s.set(marginTopKey, i.marginTop)
121 s.set(marginTopKey, i.marginTop)
116 case marginRightKey:
122 case marginRightKey:
@@ -121,6 +127,8 @@ func (s *Style) setFrom(key propKey, i Style) {
121 s.set(marginLeftKey, i.marginLeft)
127 s.set(marginLeftKey, i.marginLeft)
122 case marginBackgroundKey:
128 case marginBackgroundKey:
123 s.set(marginBackgroundKey, i.marginBgColor)
129 s.set(marginBackgroundKey, i.marginBgColor)
131+ s.set(marginCharKey, i.marginChar)
124 case borderStyleKey:
132 case borderStyleKey:
125 s.set(borderStyleKey, i.borderStyle)
133 s.set(borderStyleKey, i.borderStyle)
126 case borderTopForegroundKey:
134 case borderTopForegroundKey:
@@ -320,6 +328,18 @@ func (s Style) PaddingBottom(i int) Style {
331+// PaddingChar sets the character used for padding. This is useful for
332+// rendering blocks with a specific character, such as a space or a dot.
333+// Example of using [NBSP] as padding to prevent line breaks:
336+// s := lipgloss.NewStyle().PaddingChar(lipgloss.NBSP)
338+func (s Style) PaddingChar(r rune) Style {
339+ s.set(paddingCharKey, r)
323// ColorWhitespace determines whether or not the background color should be
343// ColorWhitespace determines whether or not the background color should be
324// applied to the padding. This is true by default as it's more than likely the
344// applied to the padding. This is true by default as it's more than likely the
325// desired and expected behavior, but it can be disabled for certain graphic
345// desired and expected behavior, but it can be disabled for certain graphic
@@ -390,6 +410,13 @@ func (s Style) MarginBackground(c color.Color) Style {
413+// MarginChar sets the character used for the margin. This is useful for
414+// rendering blocks with a specific character, such as a space or a dot.
415+func (s Style) MarginChar(r rune) Style {
416+ s.set(marginCharKey, r)
393// Border is shorthand for setting the border style and which sides should
420// Border is shorthand for setting the border style and which sides should
394// have a border at once. The variadic argument sides works as follows:
421// have a border at once. The variadic argument sides works as follows: