I can only give suggestions based on my parenting preferences, so I understand if what I can say doesn't work for you. My response is long, so I'll just start by saying, it's hard, it's not going to just "go away" or get "fixed", but you're definitely not alone in having a kid like that, and when you have one, you know that they are very much their own person and you can't just make them be different.
My parenting style is very much in line with "positive parenting" techniques, and I understand that there's an extremely helpful and supportive group on Facebook called "Positive Parenting" (my mom is active in it and really likes it; I'm not very active on FB in general. She finds it useful and is a 3rd primary caregiver in our household besides me and my husband). There are lots of books and groups and resources around focused on positive parenting, and there may be some that you find more helpful than others. And, overall, we try to demonstrate real respect--for her as a person, for her emotions, and for our own well-being--and let her be as much in control of her own life and self as we can. She's the kind of kid (180 degrees opposite of me) that we learned very early on, if she starts playing with an electrical outlet, we'd better just go ahead and teach her about outlet and plug safety, because just telling her not to isn't good enough.
Some books that I've found useful are:
- How to Talk So Your Child Will Listen, and Listen So Your Child Will Talk, by Adele Faber and Elaine Mazlich (this one is really great!)
- Parenting with Love and Logic, by Jim Fay, whose site you can find here
- Books on RIE parenting, which, if you're not familiar, you can read about here
- The Explosive Child, by Ross Greene
- The Highly Sensitive Child, by Elaine Aron
I know that last one will likely sound like it's some kind of New Age-y, "Crystal Children" kind of thing, but I swear it's not. It's been really enlightening for us. There's a theme here, though, of calm, composed, gentle reactions to your child, and I just want to say that I'm sure that probably sounds a little crazy, since the whole problem is the unpredictable, hugely-outsized reactions that logic and gentle talk can't penetrate. (And I say that with no assumptions about how much you may or may not parent with that perspective already.)
I just want to say that I, too, have a 5-year-old daughter who has tantrums like this--and I'm talking about multiple times a day, for almost no reason at all. I think I understand you, because it sounds like our kids might be similar. I use techniques from all these books in two main ways: to help me keep my presence of mind when it's all going on, and to give her words to describe and understand what's going with her. I think that, in those situations, as unexpected and unreasonable as it seems to you, it feels even more so to them. I think those big emotions are scary, and they can't always tell when they're going to have a big one versus a reasonable one.
As far as specifics, my daughter knows she's allowed to go shut herself away somewhere--she usually chooses either her room or the downstairs bathroom, but anywhere is fine. She isn't allowed to the lock the door for safety reasons, but she knows we won't burst in on her. She needs a little space to let the emotion play out. When she goes in, I'll go right outside the door and just say, softly, that I'll be there when she's ready to come out. If she's there for a long-ish time, I'll go back occasionally and just say, "Sweetheart, I just want you to know that I'm still here when you're ready." Usually, it'll blow over and then she'll have a good cry (probably the letdown from all the emotion-chemicals running their course), or occasionally she'll just start playing and by the time she comes out, all will be well.
The important rule we hold ourselves to, though, is that the feeling, the outburst, and the stuff she does and says during it don't actually have anything to do with us, so we don't need to take it personally or do anything about it (at least for her sake). We do firmly but gently correct her if she hits (not really a problem for her anyway), and if she stands there screaming at us, we'll say, "I don't like being screamed at, so I'm going to go in another room"--basically, just demonstrating self-care and self-respect. And if she says things to be hurtful, we treat it thoughtfully. It's hard, because she'll say things that are just weird to respond to, but, for instance, if she says, "Fine, you can't come to my birthday party!" we'll say, "Oh, that will make me sad," and just leave it at that. We basically try to validate what she's feeling by acting as though it's reasonable. Then, when it's over, we can talk about how she felt, what she said, how it makes her feel now, and whether she still feels that way.
Beyond that, I can tell you that I have had her evaluated by a child psychologist, because of her outbursts and some other things (sleep issues, genetic predispositions, &c.). I was concerned that she was showing signs of anxiety or a similar disorder. The results were interesting--nothing dire, no real diagnosis for now, but some indications in various areas, and a possible risk of a mood disorder. Mostly, she made suggestions for at-home and in-class, all stuff that's pretty easy to accommodate, and she strongly recommended therapy, particularly CBT (cognitive behavioral therapy)--the way they do it, I guess, which she recommended, is ~20 minutes per week in the school setting, so the therapist just comes to the school, chats with them for a bit but not too long, and that's all. I'm eagerly looking for the right therapist, because I think it will help a lot.