We provide a general formula for the partition function of three-dimensional N = 2 $$ \mathcal{N}=2 $$ gauge theories placed on S 2 × S 1 with a topological twist along S 2 , which can be interpreted as an index for chiral states of the theories immersed in background magnetic fields. The result is expressed as a sum over magnetic fluxes of the residues of a meromorphic form which is a function of the scalar zero-modes. The partition function depends on a collection of background magnetic fluxes and fugacities for the global symmetries. We illustrate our formula in many examples of 3d Yang-Mills-Chern-Simons theories with matter, including Aharony and Giveon-Kutasov dualities. Finally, our formula generalizes to Ω-backgrounds, as well as tw...