For everyone else, your assumptions were correct: Those cool color-changing pencils, cups, sunglasses, and other fun things are an example of clever science, not hocus pocus.
There are a few different ways to make something change color in specific conditions – usually either a change in temperature or exposure to UV light. Once you’ve learned how it’s done, you’ll see it everywhere (and get to ruin the magic for everyone else.)
Thermochromic Leuco Dyes
Thermochromic means something that changes color in response to a change in temperature. Leuco dyes are molecules that can appear colored or clear, depending on their environment. This is thanks to a molecular structure called a lactone ring. When the ring is open, the substance appears to be colored. When the lactone ring is closed, the substance is in its colorless “leuco” state. (Leuco comes from the Greek word “leukós,” meaning white or bright.)

In thermochromic inks, this ring open/ring closed scenario is usually controlled by combining your leuco molecule with a developer (often an acid) in a solvent solution. When you raise the temperature, the solvent melts. In most leuco dyes, an increase in heat causes the lactone ring to close, creating the colorless leuco state.

Photochromic Leuco Dyes
It’s not just heat that can create color changes! There are also photochromic leuco dyes, which change color under UV light. The science is similar to thermochromic leuco dyes, but without all that acid and solvent nonsense thrown in.

When photochromic inks are exposed to UV light, they undergo a temporary change to their molecular structure. The energy from the sun supercharges the chemicals from their baseline ground state to a high energy state, and in the process, opens up a ring (yeah, one of those) which causes the chemical to change from clear to colored. The thing is, chemicals don’t like being in a high energy state – it takes too much energy to sustain – so photochromic inks fade quickly back to clear when brought out of UV light.
Thermochromic Liquid Crystals (TLCs)
Another way manufacturers create color-changing products is with thermochromic liquid crystals (TLCs). A liquid crystal is a crystal that has properties of both solids and liquids. TLCs have a molecular structure that shifts in response to heat, which changes the wavelength of light the crystals reflect, and those wavelengths appear as different colors. As the wavelength decreases in size, the TLCs change in color from red through the visible light spectrum to blue, and vice versa.

How Color-Changing Novelty Products Work
While TLCs are cool, they’re harder and more expensive to manufacture than leuco dyes, plus they don’t mix well with other chemicals. In contrast, leuco dyes are able to withstand an impressive range of manufacturing processes, meaning they can be added to lots of different types of products, including paper, plastic, ink, and paint. Your color-changing cup/pencil/rubber duck most likely works using a thermochromic leuco dye.
Creating Two-Tone Products

Although we talk about leuco dyes changing colors, they can only move from colored to clear (or clear to colored) and back again. In contrast, TLCs can move through the rainbow, depending on the range of temperatures you expose them to. To create a two-tone effect using leuco dyes, you can mix them with paint. For example, if you mix a blue leuco dye with a pink acrylic paint, at room temperature, the blue and pink will both reflect light, making purple. As the object heats up, the blue leuco dye will gradually turn clear, so the color will appear to shift to pink.

Hidden Messages
Another way to use leuco dyes for color-changing products is to print an image behind the dye that’s slowly revealed as the dye heats up and turns clear. A good example you may have seen are mugs that reveal a photo when they heat up. The photo is printed directly on the mug using sublimation or full-color printing and then painted over with a leuco dye that’s a solid color at room temperature, but colorless at higher temperatures. When you add a warm liquid, the leuco dye goes clear and you can see the photo beneath.
Works Hot or Cold
Different types of leuco dye react at different temperatures. That’s why you can have products that change color in response to cold, and others that change in response to heat.

Touch-Activated Thermochromic Dyes: These are colored at room temperature, and start to turn clear at around 85F. These dyes are used for products that change color in response to warm temperatures, such as mood pencils, stress balls, or mugs.
Cold-Activated Thermochromic Dyes: These are clear at room temperature, and start to turn colored at around 60F. These are used in products that change temperature in response to the cold, e.g. cups, ice cream bowls, or spoons.
Both of these types of dye turn clear when heat increases. It’s just that they have different heat tolerances. The touch-activated dyes need to go above room temperature to get into their clear leuco state, whereas the cold-activated dyes will already be in their leuco state from around 60F and above. There are also leuco dyes that change from colored to clear at dangerously high temperatures (around 115F) but those are for safety features rather than novelty items!

Temperature Accuracy
Unlike TLCs, leuco dyes are not very precise. TLCs can react to temperature changes as small as only 0.2F, whereas it takes changes of at least 5F to trigger leuco dyes to switch color. And while TLCs can give an accurate temperature reading within 0.9F, leuco dyes may only respond within 6F to 18F of the intended temperature, making them unreliable when you need to know the exact temperature.
Speed and Longevity
There are lots of leuco dyes, and which one your product uses depends on factors like the manufacturing process, the material, and even the color. Each of these dyes starts to react at different temperatures, which is why different color-changing products change color at different speeds.
If you pour 40F drinks into two color-changing cups, the cup that reacts below 50F will start changing color faster than the one that reacts at 42F. This is because it won’t take long for a 40F drink to get a cup below 50F, but it takes longer for that same drink to cool a cup down to 42F.
The same goes for how long the reaction lasts. As those drinks warm up, the 42F cup will change back to its colorless state sooner than the one that reacts below 50F, because the 50F cup needs to hit a higher temperature to trigger its colorless leuco state.

The span of the reaction also depends on the mechanism of the specific dye. For example, photochromic leuco dyes will turn back to their colorless leuco state within minutes of being out of the sun, because they can’t sustain the energy needed to maintain the reaction without a direct UV source.
Examples of Color-Changing Dyes In The Wild
Novelty Products
By now you know that your color-changing sunglasses, cups, rubber ducks, pencils, etc. are made using leuco dyes.

Transition Lenses
Photochromic dyes are used on transition lenses on sunglasses, shifting them from clear indoors to dark outdoors.

Security Features
Photochromic and thermochromic leuco dyes are used as security features on documents such as IDs and passports.

pH Tests
Leuco dye molecules change color in response to pH changes, so they’re used in pH tests. (Technically, this is how thermochromic leuco dyes work too. Changes in temperature control whether the acid and leuco dye can interact or not, which is what causes the color change.)

Thermometers
Thermochromic liquid crystals are precise enough to be used in thermometers, like the ones you put in a fish tank or stick to your forehead.

Hot or Cold Alerts
Thermochromic leuco dyes let consumers know when an object is hot or cold. For example, drink cans that use a color-changing design to tell you when your beverage is the perfect drinking temperature, and pans or microwavable containers that use a color-changing red spot to tell you when the item is hot enough to eat, or even too hot to touch.

Mood Rings
Unlike most of their novelty color-changing contemporaries, mood rings use TLCs, not leuco dyes! That’s why they can move through all the colors of the rainbow, given a large enough temperature range, and not just from one color to another.

The Bottom Line
Even though we know it’s not magic, there’s still something enchanting about color-changing products. Next time you see a mood ring, or a color-changing cup, or put on a pair of transitional sunglasses, you’ll know that there’s a lot of clever chemistry behind that simple and delightful color change. It’s a level of innovation that might just be better than magic.
