Ab initio techniques is used to reveal how quantum confinement effects, surface states and structural changes modify the electronic properties of semiconducting Mg2Si and Ca2Si thin films (from 17 nm down to 0.2 nm corresponding to the 2D structure).