Can I lose child custody if I have depression and anxiety (UK)?

Of concern to many who suffer from mental health issues is the worry that they will come to the attention of their ex or social services and ultimately lose custody of their children. Sometimes this is a real consideration, particularly if a parent is suffering from severe or chronic problems.