It seems complicated.
Nesting the widget inside a button is about as simple as it gets. You can do that on a per-instance basis or create a button class that’s reusable. In either case, the color-changing widget is still its own thing that can be used in and out of buttons.
I’d argue that ensuring the widget is always placed on top of the button is going to be more work in the long run anyway.