A student killed in a school shooting in Denver, Colorado, was hailed a hero after classmates described how he attempted to tackle the gunman as shots rang out.

Kendrick Castillo led the charge against their teenage classmate with two others, one of whom managed to wrestle the gun away.

But 18-year-old Mr Castillo slumped to the ground. He was the only student to be killed, while eight others were injured.

Authorities said the actions of Mr Castillo, his close friend Brendan Bialy and Joshua Jones minimised the bloodshed from Tuesday's attack at the school south of Denver.

"Kendrick went out as a hero," Mr Bialy said. "He was a foot away from the shooter and instead of running the opposite direction he ran toward it."

"Kendrick lunged at (the gunman), and he shot Kendrick, giving all of us enough time to get underneath our desks, to get ourselves safe, and to run across the room to escape,” fellow classmate Nui Giasolli told NBC.

Some are now calling for the school to be renamed in his honour.

A member of the school's robotics club, Mr Castillo had an infectious smile and gentle sense of humour, according to friends.

He worked part-time at a local manufacturing company that had offered him a job after an internship because he was such a standout employee.

"To find he went down as a hero, I'm not surprised. That's exactly who Kendrick was," said Rachel Short, president of the company, Baccara.

Police said the shooting happened after two shooters walked into the school, "got deep inside the school, and engaged students in two separate locations".

The injured includes Mr Jones, who was shot twice, according to a statement released by his family.

Mr Bialy acknowledged that he was scared, but he said he was not going to cower for attackers he repeatedly called cowards.

"They lost," he said. "They completely and utterly lost to good people."

He was speaking as two teenagers made their first court appearances in connection with the shooting.

Devon Erickson, 18, kept his head down with his black hair, streaked with purple dye, covering his face as he nodded in response to most of District Court Judge Theresa Slade's questions.

At one point, the judge requested a verbal answer to whether he had any questions about the proceedings. Erickson simply replied "No".

Maya McKinney, 16, whose lawyer said uses male pronouns and the name Alec, and has short brown hair, made eye contact with the judge and answered questions in a clear but quiet voice, saying "Yes, your honour" and "No, your honour".

District attorney George Brauchler said he has not decided whether to file adult charges but added that McKinney is old enough to be charged as an adult without a judge's review.

Formal charges are expected to be filed by Friday. Mr Brauchler said he could not discuss any motive or weapons used in the attack.

Both suspects were students at the school, and they were not previously known to authorities, officials said.