Why is the foam of a shampoo always white irrespective of the colour of the shampoo?
To understand this better, let’s use an analogy. When a balloon is deflated, it is opaque with its colour very much visible. As we go on inflating the balloon, it becomes lighter in colour. If we continue to inflate the balloon without bursting it, there will come a point when it will become almost white. The same is the case with the bubbles that form in the foam of a shampoo. The pigments in the shampoo become so thin when mixed with water that the visible light gets scattered. The light rays get reflected in several directions after striking a surface (bubbles in this case) much like how the sky appears white or grey at times. Also the dye that is used in colouring a shampoo is highly diluted, which means that when further diluted with water, the colour becomes much lighter.
The scattering of light in case of the foam happens as the light has to pass through several bubbles, which means several surfaces. The light spreads in multiple directions making it almost impossible for the human eye to detect colours. The same thing happens with soap bars, body washes, hand washes etc.