The U.S. Supreme Court on Wednesday ruled that a school district violated the First Amendment when it punished a teenaged student for vulgar comments posted to social media while she was off campus.

The justices, in an 8-1 opinion by Justice Stephen Breyer, declined to rule that school districts have no right to regulate off-campus speech. “The school’s regulatory interests remain significant in some off-campus circumstances,” Breyer wrote.