pH indicators operate based on the principle of acid-base reactions. They contain molecules that can donate or accept protons, thereby changing their structure and color. For instance, in acidic environments, the indicator may donate a proton and exhibit one color, while in basic environments, it may accept a proton and show a different color.