The legal basis for civil commitment can be found in the Supreme Court decision of Kansas v. Hendricks ( 1997).
A civil commitment is a legal process through which an individual who is deemed dangerous for the general public ( severe mental disorder), is order by court into treatment or a prolonged stay in an appropriate and secure treatment facility. It also apply to prisoners who, after serving their prison sentence, are still considered dangerous and therefore can not be granted freedom.
Kansas v. Hendricks was a U.S Supreme Court decision where two predators, Leroy Hendricks and Tim Quinn, were ordered to indefinite civil commitment after finishing their prison sentence. They were both convinced of inappropriate behavior towards children. During the trial they both admitted to feeling strong desire towards children when under extreme stress. The court considered them to be violent predators and ordered them to indefinite civil commitment.