3 yellow onions, halved through the root ends and thinly sliced
2 garlic cloves, chopped
3 sprigs fresh thyme, leaves removed
1 tablespoon sugar
1 tablespoon kosher salt
1 teaspoon freshly ground black pepper
1/4 cup sherry vinegar
Melt the butter in a large saucepan over medium-low heat. Add the onions, garlic and thyme leaves, and stir. Cover and cook, stirring frequently, until the onions are deep golden brown, 45-60 minutes.
Add the sugar, salt and pepper. Stir, replace the lid and cook for 10 minutes.
Add the vinegar and scrape up any browned bits in the pan, mixing it into the onions. Cook until the liquid has evaporated, about 10 minutes. Transfer to a container and let cool completely, then cover and refrigerate for up to 2 weeks.