Sunglasses or prescription eyeglasses that darken when exposed to the sun were first developed by Corning in the late 1960s and popularized by Transitions in the 1990s. In fact, because of the extreme popularity of the Transitions brand, these lenses are usually referred to as transition lenses. The correct term for these glasses is photochromic or photochromatic, which refers to a specific chemical reaction the lenses have to ultraviolet (UV) radiation.
Photochromic lenses have millions of molecules of substances such as silver chloride or silver halide embedded in them. The molecules are transparent to visible light in the absence of UV light, which is normal for artificial lighting. But when exposed to UV rays, as in direct sunlight, the molecules undergo a chemical process that causes them to change shape. The new molecular structure absorbs portions of the visible light, causing the lenses to darken. The number of molecules that change shape varies with the intensity of the UV rays.
When you go indoors and out of the UV light, a different chemical reaction takes place. The absence of the UV radiation causes the molecules to "snap back" to their original shape, resulting in the loss of their light absorbing properties. In both directions, the entire process happens very rapidly.
In the original PhotoBrown and PhotoGrey products made by Corning, the lenses are made of glass, and the molecules are distributed evenly throughout the entire lens. The problem with this method was apparent in prescription glasses where different parts of the lens were of varying thickness. The thicker parts would appear darker than the thinner areas. But with the increasing popularity of plastic lenses, a new method has been developed. By immersing the lenses in a chemical bath, the photochromatic molecules are actually absorbed to a depth of about 150 microns into the plastic. This is much better than a simple coating, which would only be about 5 microns thick and would not provide enough molecules to make the lenses sufficiently dark. This plastic lens absorption process has been popularized by Transitions, the leading manufacturer of photochromic lenses.
An important note about photochromic lenses: because they react to UV light and not to visible light, there are circumstances under which the darkening will not occur. A perfect example of this is in your car. Because the windshield blocks out most UV light, photochromic lenses will not darken. For this reason, most sunglasses with photochromic lenses also have a certain amount of tint already applied to them.
Here are some useful links: