The easiest way to know how to care for your leggings is to read each pair's individual label for washing and drying instructions. Each pair of instructions will be unique because the right way to wash and dry them will depend on the materials the leggings are made from. Most manufacturers remember to include that information on the leggings' inner label, but if your leggings, for whatever reason, didn't come with a label, or if that label has been lost or damaged, read on below!
First thing's first: if your leggings are damp and less than fresh after a hard workout, the first thing you should do is take them off and hang them up. If they stay bunched up in your sweaty gym bag, you run the risk of mildew and mold growing and spreading, which looks and smells aweful. It's an easy problem to avoid, even when you're exhausted.
If your leggings have mesh material or detailing that could snag in the washer, place them in a mesh bag for cleaning. This will prevent tears or other types of damage.
Because leggings are typically made of synthetic materials like spandex, it's best to wash them with cold water. People often assume that because their clothes get all sweaty, they should use hot water to prevent bacteria from forming, but you run the risk of damaging your leggings if you run them on anything but a cold, gentle cycle.
Another note about clothes made from synthetic materials: it's best to wash them separately from other clothing materials. Towels and cotton shirts cause lint balls to get stuck to leggings in the wash, while garments with features like zippers (looking at you, blue jeans) could rip or tear your favorite pair of leggings. Even when you wash your two favorite pairs of leggings together, it's best to turn each inside out to reduce friction on the leggings' outer finish.
Athletic leggings typically have moisture-wicking technology in the materials they're made from, but if you use fabric softener, which contains silicone that coats the fibers of your clothes to make them feel silky, you could actually limit your leggings' breathability and capability to keep you from getting sweaty during your workouts. So if you're thinking about using fabric softener to wash your leggings: don't! (If you've already washed them with fabric softener by mistake, don't panic! Just wash them again without it for an easy fix. They should return to their normal wicking capabilities afterward.)
Most importantly: choose the right detergent. There are detergents out there that are made to wash the synthetic materials your leggings are made from, so use them. Also, be sure not to use too much detergent when washing your leggings. Too much detergent can leave your leggings feeling icky, but on a more sanitation-minded note: leftover suds can also trap bacteria and odor as well as cause skin irritation.
Lastly, avoid using the dryer at all costs. Heat damages and weakens the leggings' synthetic materials; your leggings will be able to retain their shape better if they're hung up away from heat or direct sunlight.