adverb, noun, na-adjective
as one wishes; as one pleases; to one's heart's content
Expresses doing something freely, without restraint, exactly as one desires. Often used adverbially with に or as a noun with だ/の.
休日は思うままに過ごしたい。
I want to spend my day off as I please.
彼は思うままの人生を送っている。
He is living life on his own terms.
思い通り is more common and neutral for 'as one wishes', while 思うまま has a slightly more literary or emotive nuance of following one's heart's desire without restraint.
Compound of 思う (omou, 'to think, feel') and まま (mama, 'as it is, condition'). The exact historical derivation is straightforward; まま indicates the state of one's thoughts or desires.