That will depend a lot on pressure, airflow and fan-design, but I think 10mm is a good minimum starting point. There are also fans that have open sides, with some having their propeller designed around. They will still not like having a completely closed-off top, so always leave a little room, like 5mm.
None of this is scientific but experience from playing with fans. Which I recommend you to do too to test the results.