This time 2 years ago I had a over month off with stress. Not all of it was work related, (my health, partner's mental health, parent's health, house move, two kids doing exams etc.) but the tipping point for me was the lousy manager and super frustrating job and employer.
I started looking for a new job while off, it took about 9 months (relatively niche role), but I landed the dream job. It was more responsibility (senior management) for more money with a fantastic pension scheme, in a better location with fabulous colleagues in a world leading facility.
Due to a long notice period, I started around 11 months ago. The last year has been amazing! I've had the best year of my professional life and have just been promoted! that was something I was hoping for but expected to have to do further qualifications and another 18 months experience minimum.
Taking time off to get my head straight was absolutely the best thing to do under the circumstances. I'd not realised just how bad things were until I got out of that toxic environment. Gaining perspective on the situation by removing myself from the biggest cause of stress was the key.
When I applied for my new job, I was asked about time off due to ill health and I was honest on the questionnaire about mental health. It wasn't a barrier for me. Your mileage may vary obviously, but you've got to put your mental health first. If a future employer turns you down then they don't deserve you.
I hope everything goes well for your job hunt and that your next job is everything you're looking for.