There is no special provision in the UK constitution for the removal of a Prime Minister on mental health grounds.
The Prime Minister is primus inter pares in the Cabinet system of government. In the unlikely situation of the Prime Minister suffering from a serious mental breakdown, the Cabinet could remove her. The office of Prime Minister is appointed by the Crown on the advice of her Ministers. A Prime Minister that had suffered a mental breakdown could be removed by the Crown, on the advice of her Ministers. Such a situation would be extremely unusual, indeed without precedent.
Under UK law, a person can be detained involuntarily. This is called "sectioning" (because you are detained under powers described in one or another section of the Mental Health Act). While sectioning would de facto prevent a Prime Minister from chairing the Cabinet, leading the government, or representing the country, it is extremely unlikely that sectioning would occur.
Far more likely, in the case of a mental breakdown is voluntary resignation. Sectioning is rare. Most mental health patients enter hospital voluntarily and remain at their choice. Sectioning is only when the patient has not been able to get early support and whose mental health has deteriorated to the point that they are a danger to themselves. The Prime Minister is surrounded by supporters, advisors and aides. She would be much more likely to receive timely support, and the chance of a situation developing in which she was removed against her will is very unlikely to occur.