Photochromic lenses have existed in one form or another since the 1960s. The technology has changed a lot since then, but the fundamental principles remain the same.
In general, these lenses work by using chemical reactions that are triggered by UV exposure. The result of the chemical reaction is a color change in the lens.
The very first photochromic lenses were made of glass and coated with silver chloride and silver halide, among other molecules. These silver compounds underwent a chemical change when they interacted with waves of UV light. The chemical change caused them to darken. The reaction reversed when the UV light was gone.
Today, the lenses are made from several different materials. Proprietary photochromic dyes are added to these materials in a variety of ways. The molecules within these dyes undergo color changes at different rates when exposed to UV light.
The lenses should darken in proportion to the amount of UV light they receive. This means that the brighter it is in your environment, the darker your lenses become.