Motivated by the counting results for color-critical subgraphs by Mubayi [Adv. Math., 2010], we study the phenomenon behind Mubayi's theorem from a spectral perspective and start up this problem with the fundamental case of triangles. We prove tight bounds on the number of copies of triangles in a graph with a prescribed number of vertices and edges and spectral radius. Let n and m be the order and size of a graph. Our results extend those of Nosal, who proved there is one triangle if the spectral radius is more than √ m, and of Rademacher, who proved there are at least ⌊ n 2 ⌋ triangles if the number of edges is more than that of 2-partite Turán graph. These results, together with two spectral inequalities due to Bollobás and Nikiforov, can be seen as a solution to the case of triangles of a problem of finding spectral versions of Mubayi's theorem. In addition, we give a short proof of the following inequality due to Bollobás and Nikiforov [J. Combin. Theory Ser. B, 2007]: t(G) ≥ λ(G)(λ 2 (G)−m) 3 and characterize the extremal graphs. Some problems are proposed in the end.