The trick is electrochromic gel. Most of the time, this gel is transparent. However, if it receives an electrical charge, it will start to darken due to oxidation-reduction.
Inside your rearview mirror, you will find the gel sitting between two pieces of glass. A special sensor can detect the glare. The sensor signals a special processor that then sends an electrical charge through the gel. This makes the gel darken, which makes the mirror "auto-dim." Take a test drive today and see this technology magic for yourself.