ALICE is an experiment mainly dedicated to the study of the quark-gluon plasma (QGP), a state of nuclear matter where quarks and gluons are deconfined, due to high temperature and density. The production of quarkonia, bound states of either a charm and anti-charm quark pair for charmonia or a bottom and anti-bottom quark pair for bottomonia, is a very useful probe of this state of matter. Indeed, the presence of the QGP modifies their production yields, due to a competition between medium-induced suppression and, at least for charmonia, a recombination mechanism in medium or at hadronization. The measurement of quarkonium production in proton-proton (pp) collisions is also essential to investigate its production mechanism as well as to test quantum chromodynamics (QCD) models. It also provides a reference for the investigation of the properties of the QGP in nucleus–nucleus collisions. Measurements in proton–nucleus collisions allow one to study the cold nuclear matter effects. In addition, high multiplicity pp collisions are useful to investigate multiparton interactions and to search for collectivity in small systems. In this contribution, we will report on the latest quarkonium production results, obtained with the ALICE detector in pp collisions, for different center-of-mass energies, at midrapidity and forward rapidity. We will also present the measurements of the quarkonium nuclear modification factor in p–Pb collisions at sNN=8.16TeV. Finally, in Pb–Pb collisions at sNN=5.02TeV, we will report on the new ψ(2S) measurement, the nuclear modification factor of the prompt and non-prompt J/ψ, as well as the first measurement of quarkonium polarization, the latter carried out also as a function of the event plane. All the measurements will be compared to theoretical predictions.