A spiropyran is a 2H-pyran isomer that has the hydrogen atom at position two replaced by a second ring system linked to the carbon atom at position two of the pyran molecule in a spiro way. So there is a carbon atom which is common on both rings, the pyran ring and the replaced ring. The second ring, the replaced one, is usually heterocyclic but there are exceptions.
When the spiropyran is in a solution with polar solvents or when it receives heating (thermochromism) or radiation (photochromism) it becomes coloured because its structure has changed and it has been transformed into the merocyanine form.
The structural differences between spiropyran and merocyanine form is that, while in the first one the ring is in the closed form, in the other one the ring is opened. The photochromism is due to electrocyclic cleavage of the C-spiro-O bond with photoexcitation.