A photonic crystal colorimetric sensor changes visible color to detect and distinguish volatile compounds through dye-photonic crystal combinations and pattern-based responses.