Melt the butter in a large skillet over medium-low heat.
Add the sliced onions and a pinch of salt and cook, stirring every few minutes, for 25 to 30 minutes, until the onions are deeply golden brown and jammy, not just softened.
Stir in the thyme and balsamic vinegar during the last 2 minutes of cooking, then remove the skillet from the heat and let the onions cool for 10 minutes.
Preheat the oven to 350°F and line a rimmed baking sheet with parchment.
Arrange 30 mini phyllo shells on the baking sheet.
Spoon about 1 teaspoon of caramelized onion into each shell.
Top each cup with a pinch of shredded gruyere.
Bake for 5 to 6 minutes, until the cheese is fully melted and just starting to brown at the edges.
Serve warm within 20 minutes of baking.
Good to Know
Caramelize the onions up to 3 days ahead and refrigerate; fill and bake the shells the day of the party.