this little resource simply lets you use multiple boxes and stack each style. is it efficient? no idea. does it work? yes. handy for some more complex themes and reduces otherwise necessary node-stacking to get the same effect.

I’ve made this because someone was looking for two-colored outlines, which are not possible by default.
you can mix arbitrary styleboxes with this, if you ever needed a styleboxtexture and a styleboxflat in one for example. or simple multicolor borders like here:
this is a tool script, make sure to reload the scene after adding it to a scene.
disable draw center if you can’t see styles earlier in the array.
@tool
class_name StyleboxStack
extends StyleBox
@export var style_boxes: Array[StyleBox] = []:
set(new_style_boxes):
for box in style_boxes:
if is_instance_valid(box):
box.changed.disconnect(emit_changed)
style_boxes = new_style_boxes
for box in style_boxes:
if is_instance_valid(box):
box.changed.connect(emit_changed)
func _draw(to_canvas_item: RID, rect: Rect2) -> void:
if style_boxes.is_empty():
return
for box in style_boxes:
box.draw(to_canvas_item, rect)
# not entirely sure if these are needed, but added for completeness
func _test_mask(point: Vector2, rect: Rect2) -> bool:
return style_boxes.any( # if any can be clicked, everything can be
func is_mask_clicked(style_box: StyleBox):
return style_box.test_mask(point, rect)
)
func _get_minimum_size() -> Vector2:
return style_boxes.reduce(
func find_biggest_minimum(biggest: Vector2, box: StyleBox):
return biggest.max(box.get_minimum_size()),
Vector2.ZERO
)
license cc0
feel free to post what you made with it ![]()
