In general it takes an extremely small amount of dye to colour a compound. If you read the list of ingredients on the package of any kind of shampoo or food, you will see the colouring agent as one of the last things listed. That means there is very little of it since ingredients are listed in order of quantity. In fact there's only a trace of dye in any coloured food or shampoo type product. Dye creates colour by absorbing visible light at a particular wavelength or range of colour spectrum. A small amount goes a long way. Just note some day how one drop of food colouring can colour an entire pitcher of water. The dye they use in shampoo is water soluble so it simply rinses out and does not remain in your hair. The dye they use for hair colour is specially designed to form chemical bonds with your hair so that it stays. In fact it usually requires multiple steps of chemical treatment to make it stay.
The white appearance of lather is caused by the dispersion of light of all wavelengths due to the millions of tiny bubbles in the foam and this makes it appear white. This effect totally overwhelms the colouring effect of the few dye molecules that were added to the shampoo to colour it.
making a small donation to science.ca.