Abstract We discovered that yttrium-, lanthanum- and rare earth-hydride films exhibit remarkable optical properties near their metal–insulator transition: the dihydrides are metallic and shiny while the trihydrides are semiconducting and transparent. The transition between the shiny and transparent state is reversible and can simply be induced by changing the H 2 gas pressure or the voltage in an electrolytic cell. No deterioration of the films is detected if they are protected by a thin palladium caplayer. The optical switching is also observed in hydrides of alloys of Y and La. Several theoretical models leading to an insulating and transparent trihydride state are discussed.