Micropatterned titanium dioxide thin-film electrodes exhibit efficient diffraction in the presence of aqueous or nonaqueous electrolyte solutions. The diffraction efficiency can be modulated electrochemically. At the wavelengths examined, the modulation is caused by changes in both real and imaginary components of the refractive index. The index changes, in turn, are caused by the addition of electrons to near-band-edge trap sites and by optical absorption by the trapped electrons. The onset potential for diffraction modulation provides a good measure of the potential of the electrode's conduction bandedge. Variable excitation wavelength measurements show that, after correction for absorption losses, the electrochemically induced changes in the proportion of light diffracted can be either positive or negative. The signs and the relative magnitudes of the wavelength-dependent changes are well described by a Kramers-Kronig analysis that assumes that changes in the real component of the refractive index dominate the response.