Thin, Pd-capped metallic films containing magnesium and first row transition metals (Mn, Fe, Co) switch reversibly from their initial reflecting state to visually transparent states when exposed to gaseous hydrogen or following reduction cathodic polarization in an alkaline electrolyte. Reversion to the reflecting state is achieved by exposure to air or by anodic polarization. The films were prepared by co-sputtering from one magnesium target and one manganese, iron, or cobalt target. Both the dynamic optical switching range and the speed of the transition depend on the magnesium-transition metal ratio. Infrared spectra of films in the transparent, hydrided (deuterided) states support the presence of the intermetallic hydride phases Mg3MnH7, Mg2FeH6, and Mg2CoH5.