As others have mentioned: the length of time will vary from person to person based on their comfort level and responsibilities.
Guaranteeing that you have 6 months to find a new job, foot a surprise medical bill, or otherwise provide for your family, but mana not getting the best returns, might be worth it to someone to avoid the stress associated with those events.
The point is that it’s at a level you are comfortable with and that’s going to be different by person.
This "6 months" time frame is different for everyone - I keep over a year in cash.
Not even bonds/CDs - just a high yield account. It is instantly accessible when I need it.
If and when the market ever drops 30+% and a recession starts to loom (seems pretty close to what's going on now) - I never have to worry will I be okay, what if I lose my job, what if I get hit with some massive unexpected expense.
I have money in the bank to get me through it all. I won't be forced to sell any equity at a time when its worth a lot less, I won't have to change my lifestyle one iota.
That security is worth the potential loss of future gains. I already have a lot in the market anyway and I keep adding more.
I'm also single with no kids so 1+ year in cash looks very different for me vs someone married with kids and all the associated costs. Even so, it's an approach I find very comforting and I hope to maintain when I'm further along.
From what I've heard, 6mo is set as such in the case if somebody gets laid off and it takes that long for them to find another job - so they have exactly that amount of raw cash to survive on for rent/food/miscellaneous.
Also medical bills tend to be twice as expensive as what you'd think they are, so a single medical incident can wipe out a solid chunk of that 6mo net.