Seven children have been killed and at least 57 injured after a classroom collapsed in Kenya's capital Nairobi, officials said.

Television stations showed images of rescue workers sifting through metal sheeting and slabs of concrete at the Precious Talent School, and carrying white body bags to an ambulance.

"There have been 57 students that have been taken to hospital for treatment, and we can also confirm that there have been seven fatalities," said a government spokesman.

Kenyatta National Hospital later said on Twitter that 64 students had been sent to the hospital.

The first floor of the building collapsed, trapping the children below, a local politician told NTV Kenya.

Hundreds of angry residents of Dagoretti - a poor area where many live in makeshift houses - swarmed around the site where rescuers picked through the rubble of the classroom.

The building collapsed shortly after 7am local time as pupils entered the classroom.

The cause was not immediately known, but authorities have previously warned 30-40,000 buildings erected without approval in Nairobi are at risk of collapse.

Three years ago, a six-storey residential block collapsed in Nairobi, killing 51 people following heavy rains.