Magnesium hydroxide is used to treat occasional constipation in children and adults on a short-term basis. Magnesium hydroxide is in a class of medications called saline laxatives. It works by causing water to be retained with the stool. This increases the number of bowel movements and softens the stool so it is easier to pass.
Magnesium hydroxide come as a chewable tablet, tablet, and a suspension (liquid) to take by mouth. It usually is taken as a single daily dose (preferably at bedtime) or you may divide the dose into two or more parts over one day. Magnesium hydroxide usually causes a bowel movement within 30 minutes to 6 hours after taking it. Follow the directions on the package or on your product label carefully, and ask your doctor or pharmacist to explain any part you do not understand. Take magnesium hydroxide exactly as directed. Do not take more or less of it or take it more often than prescribed by your doctor.
Summary from MedlinePlus.gov, click for more information.