Lenses that darken automatically when exposed to various levels of light are called photochromic or light-adaptive lenses. This technology was discovered in the 1960s, but it didn’t really catch on until the 1990s. The convenience of photochromic lenses is huge: they’re basically like getting two complete pairs of glasses—regular glasses and sunglasses—in one!
How the technology works is pretty cool. In glass photochromic lenses, silver compounds are embedded into the lens material. When exposed to varying levels of sunlight, the compounds go through a chemical change that increases their size, allowing them to block out more light. Once the bright sunlight subsides, the molecules return to their normal size. Plastic light-adaptive lenses use similar photochromic molecules to create the darkening effect. The reaction that causes the material to darken as it absorbs varying levels of light is completely reversible which is why the lenses go back to clear or only slightly tinted when the wearer is out of bright sunlight.
The only issue you may encounter with light-adaptive lenses is that the photochromic reaction depends to some extent on temperature. In very hot weather, they may not darken all the way. When you first step into the sunlight, the darkening effect happens in about a minute. Over the next several minutes, they may darken just a little more, until achieving their final darkness after about 15 minutes (which depends on the brand and material of lenses). The first reaction will be drastic and give you more than enough light protection to continue into the sun with your vision protected.
If the final darkness of regular light-adaptive lenses isn’t dark enough for what you need, photochromic sunglasses can help. Their darkness when not in the sunlight is still darker than normal glasses. For that reason, most people don’t use these as their only pair of glasses because they won’t see as well indoors. They are a great option for people like drivers, for example, who spend a large part of their time shielding their eyes from sunlight and can wear their backup glasses in low-light settings. The other reason they’re good for drivers is that most windshields block out the UV light that causes the darkening reaction. With a UV-blocking windshield, bright light coming through your windshield will not cause your lenses to darken, leaving you squinting and straining.