I do this as well!! It's gets pretty difficult for my partner and I when this happens. Here's what helps us:
We both have the mindset of "us versus the problem" (the problem being my mood disorder most of the time) and that helps. It's important for you to communicate to your partner when you aren't lashing out what's going on with you when you are. The feelings and thoughts you have. That you don't want to be this way. The struggles you face when trying to control these emotions. And it's very important for your partner to actively try to be mindful and not take offense to things. It's hard but very possible. Your partner shouldn't only be understanding with the easy parts of mental illness. The hard parts are when someone shows a true understanding of what it means to support someone who has mental illness. Not taking things personally is a huge way my partner helps me when I'm like this.
Work on identifying when you're in a mood swing instead of a genuine moment of being upset. Identifying when it's happening is a moment of opportunity to say something to your partner like "I'm incredibly angry right now and it's a mood swing so please dont take offense to how im acting right now and ill work on calming down"
It's also important to check in with your partner after everything calms down! Reassurance of your love for one another and apologizing for things you didn't want to do or say.
We often feel out of control and at the mercy of our emotions. It's a bad time for everyone involved lol but you can learn to navigate it in ways that work for you! It took years for my partner and I to be able to handle these situations with ease lol but we are much stronger for it.
I hope this helps! 💕