Answer:
Modern photochromic glasses, usually made of plastic, contain carbon-based molecules that change their molecular structure when UV light strikes them (and thus they absorb more light) and become dark. Similarly, in the absence of UV light, the molecules reverse to their original shape, making the glass clear once again.
Some facts:
Photochromic glasses may be made of different materials, including glass, plastic or polycarbonate. Photochromic lenses were invented by William H. Armistead and Stanley Donald Stookey of Corning Glass Works in the early 1960s. The design of those preliminary glasses, however, was quite different from the ones we commonly see these days.