Abstract Metallic magnesium lanthanide thin films upon insertion of hydrogen transform to a highly transparent hydride phase. With a Pd overlayer, the transformation can be produced either by electrochemical insertion of hydrogen or by exposing the film to hydrogen gas. Unlike amorphous oxide electrochromics, the transformation is accompanied by a large change in visible reflectance (about 50%). The optical switching effect in these materials is investigated in terms of changes in the complex refractive index as determined by variable-angle spectroscopic ellipsometric and normal-incidence radiometric measurements over the solar spectrum. Furthermore the optical effect of converting the Pd cap-layer to Pd–H was determined. It is shown that the Pd layer limits the visible transmittance of the hydrided stack to about 35–40%. Whereas the extinction coefficient of the dehydrided LnMg-layers at 550 nm is between 2.2 and 3.1, it is as low as 10 −4 in the transparent state.