Cook County Sheriff Tom Dart is running into a backlash from the Cook County public defender and other legal advocates of people who are remaining in jail as his office scrutinizes if they have violent backgrounds that should bar them from court-ordered home confinement under electronic monitoring.

Taphia Williams sued the sheriff’s office in federal court this week, saying Dart unconstitutionally kept her in jail for more than 60 hours even though a non-profit group had posted bail so she could go free on electronic monitoring as her case was pending. Her attorney, Sara Garber, is asking for class-action status.

“It is your obligation to provide security at the jail, not pick and choose its residents,” Cook County Public Defender Amy Campanelli wrote to Dart on Wednesday.

Williams is charged with aggravated kidnapping, armed robbery, aggravated battery, aggravated domestic battery and unlawful restraint. On Sept. 15, she entered Cook County Jail, where she remained because she couldn’t post 10 percent of her $250,000 bond.

On Oct. 31, her bond was reduced to $50,000 and on Friday the nonprofit Chicago Community Bond Fund posted the $5,000 for her release. On Monday afternoon, a representative of the nonprofit called the jail to ask why Williams wasn’t released, according to the lawsuit. He was told Williams was being held because of Dart’s policy to review people with “serious charges,” the lawsuit said.

According to the sheriff’s office, Williams was released into electronic monitoring Monday night after her case was examined and she wasn’t deemed a public-safety threat. She will stay with an uncle.

A Go Fund Me site established for Williams’ legal defense says her charges stem from a fist fight between her brother and a man who had been subjecting her to domestic violence.

Williams’ lawsuit comes on the heels of a letter Dart sent to Cook County President Toni Preckwinkle and other county officials on Feb. 22. In the letter, Dart said his office studied felony gun cases in late 2016 and 2017 and found only 2 percent of the defendants in 2016 were released on electronic monitoring — while 22 percent of the defendants in 2017 were placed in the program.

In his letter, Dart said his office would scrutinize everyone assigned by the courts to electronic monitoring — a program his office runs. Those deemed to pose too high a security risk would be referred back to the court for more evaluation, he said.

Over the past week, the sheriff’s office determined that eight defendants were ineligible for court-ordered electronic monitoring, records show.

One of them was arrested by the Chicago Police fugitive apprehension unit on a warrant for aggravated battery with a handgun — a charge later upgraded to attempted murder. The court originally ordered the man held without bond, then reduced his bond to $75,000 with electronic monitoring on Feb. 22, the records show. Another man, charged with gun possession, was previously arrested in connection with a murder, but was ordered into electronic monitoring, too.

In an email exchange obtained by the Sun-Times, Campanelli wrote to the sheriff’s office that its actions are “outrageous.”

“I will do everything in my legal power to stop the sheriff from usurping the power of the judiciary and the other stakeholders who presented evidence at a lawful hearing in order to set bond,” she wrote Tuesday night.

On Wednesday, Cara Smith, chief policy for Dart, sent an email to Campanelli that her “outrage is misplaced.”

“We will not permit someone to be placed on the program that we believe is ineligible or cannot be safely monitored in the community,” she wrote.

Campanelli also sent a formal letter to Dart on Wednesday that said, in part, “As the sheriff, you do not have the authority to hold someone because you disagree with a judge’s ruling.”

She also took issue with a line in Dart’s Feb. 22 letter that said, “many of these individuals are immediately returning to communities plagued by gun violence.”

“Sadly that smacks of racial and geographic discrimination,” Campanelli wrote. “I certainly hope you are not advocating that release decisions be controlled by the neighborhood where someone lives.”

Dart, meanwhile, is facing other legal challenges involving his policy on vetting candidates for electronic monitoring.

Jonathan Bedi, an attorney for Gregory Cooper, said he’s filed a motion for Dart to explain to the court why he didn’t release his client on electronic monitoring. A hearing is set for Friday, Bedi said.

Cooper, 34, is in jail on a heroin-related charge. Dart’s office says Cooper was ineligible for electronic monitoring because he was on bond on a charge of aggravated carjacking at the time of his latest arrest.