Detecting when an object with surface mount component?
I'd suggest you try an APDS-9960 based solution, this works out to several inches.
The chip is about $2 in qtyenter link description here, and is very reasonable as a small board solution available from Sparkfun or on Ebay, prices from $4 -$16. 



I've used several of these $4 Ebay modules and they work just great.