It is shown that thin layers of palladium coated magnesium lanthanide alloys reversibly go through an optical transition by variation of the hydrogen concentration, just as has recently been shown for pure lanthanides. With these layers optical switches can be constructed that exhibit three different optical states: a color-neutral transparent state at high hydrogen concentration, a nontransparent dark absorbing state at intermediate hydrogen pressures, and a highly reflective metallic state at low hydrogen pressures. The ratio in transmission between the transparent state and the reflecting state is more than 1000. (C) 1997 American Institute of Physics.