It's a combination of three factors: diluted liquid soap, combining air with the soap in the pump and nozzle, and chemicals called surfactants, which make the bubbles more stable.
Soap foam results from mixing soap with air under pressure as the pump is activated. The soap and air are in separate chambers and are combined at the nozzle.
The secret to turning liquid soap into foam is in the pump at the top . The liquid soap mixed with a small amount of water is drawn through the straw and pumped out . The way it works is the oxygen within the water is diffused through the aerator and appears as foam