Can I take magnesium while pregnant?

I was wondering if I can take it and what kind would be more recommended.