The most common water softening method called "ion exchange," is a reversible chemical process of exchanging hard water ions for soft water ions.
Calcium and magnesium are the hardness ions, sodium can be considered the "softness" ions and they are exchanged to create soft water.
Ion exchange takes place in a "resin bed" made up of tiny bead-like material often made of styrene and divynlbenzene. The beads, having a negative charge, attract and hold positively charged ions such as sodium, but will exchange them whenever the beads encounter another positively charged ion, such as calcium or magnesium minerals. This ion exchange happens very easily since the sodium ions have a positive charge of only one, while magnesium and calcium have a more powerful positive charge of two.