Eggs, especially the whites, have a pH level of 7.6-9.5, making it an alkaline environment for the onions. Anthocyanins, the pigments in red onion in particular, react with acidic or alkaline ingredients and causes the color of your onions (and eggs) to change. Acidic ingredients cause their red-purple color to brighten and intensify, while exposure to alkaline ingredients – like eggs—will cause it to turn blue or green.