Not a dumb question because I don't know the answer to that question! Following because I was planning a microwave cabinet when we remodel our kitchen eventually and hadn't even thought about that.
We had a microwave cabinet at a house we rented. The owners left a small older microwave and we switched it out for our microwave that was newer and larger. We left the cabinet door open during and after use to prevent it from overheating. There was space around all of the sides, but possibly not enough because it died prematurely. So I’d check the clearances recommended in the microwave users manual.