In the comments of a hack showing hair accessories stored in a plastic cleaning tote, Mia shared her method, which may work even better for some:
We've started using a tackle box to store my daughter's hair accessories. The bottom is big enough for brushes, detangler, etc.
It can be closed to prevent the baby from tasting the barrettes, and when it turns over the mess stays inside. And sorting the accessories into the different trays seems to keep my daughter distracted while I detangle.
I found a cute pink and purple tackle box on Amazon, but you can also find tackle boxes in sporting goods stores and craft stores.