Taklif (legal accountability for actions) is removed from a person who is mentally ill, because it was authentically reported that the Prophet (peace be upon him) said,
“The Pen is stopped from recording the deeds of three...”
and he (peace be upon him) mentioned those who are mentally ill, until they recover. As for anything that they may damage, they are compensated for by their guardians. May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.