Vegetable fats such as palm and coconut oil are warmed until liquid. Stearic acid is often added because it makes the lather denser and longer lasting.
An alkali splits the fats and bonds with the fatty acids to make soap. Potassium hydroxide gives a soft soap that foams easily, unlike the hard bar soap made with sodium hydroxide. Triethanolamine is another common choice.
The soap is stirred with water, glycerin, emollients and emulsifiers into a smooth cream. A typical cream is 20 to 30% soap with up to about 10% glycerin.
A measured dose of cream is pumped into each can. Personal care foams often use aluminum cans, and others use lacquered tinplate.
A valve is seated in the can's opening and its cup is crimped tight to the inside rim. The valve design sets how fast the foam comes out.
Liquefied hydrocarbon gas is forced in through the valve, up to about 10% of the contents. Inside the can it stays partly liquid, refilling the headspace as foam is used. Because the gas is flammable, these filling machines often sit in a separate gas house.
An actuator with a shaped nozzle is pressed onto the valve stem, then the cap goes on. A spring in the valve closes it each time the button is released.