Context.Observations of polarized radio emission show that large-scale (regular) magnetic fields in spiral galaxies are not fully axisymmetric, but generally stronger in interarm regions. In some nearby galaxies such as NGC 6946 they are organized in narrow magnetic arms situated between the material spiral arms. Aims. The phenomenon of magnetic arms and their relation to the optical spiral arms (the material arms) calls for an explanation in the framework of galactic dynamo theory. Several possibilities have been suggested but are not completely satisfactory; here we attempt a consistent investigation. Methods. We use a 2D mean-field dynamo model in the no-z approximation and add injections of small-scale magnetic field, taken to result from supernova explosions, to represent the effects of dynamo action on smaller scales. This injection of small scale field is situated along the spiral arms, where star-formation mostly occurs. Results. A straightforward explanation of magnetic arms as a result of modulation of the dynamo mechanism by material arms struggles to produce pronounced magnetic arms, at least with realistic parameters, without introducing new effects such as a time lag between Coriolis force and α-effect. In contrast, by taking into account explicitly the small-scale magnetic field that is injected into the arms by the action of the star forming regions that are concentrated there, we can obtain dynamo models with magnetic structures of various forms that can be compared with magnetic arms. These are rather variable entities and their shape changes significantly on timescales of a few 100 Myr. Properties of magnetic arms can be controlled by changing the model parameters. In particular, a lower injection rate of small-scale field makes the magnetic configuration smoother and eliminates distinct magnetic arms. Conclusions. We conclude that magnetic arms can be considered as coherent magnetic structures generated by large-scale dynamo action, and associated with spatially modulated small-scale magnetic fluctuations, caused by enhanced star formation rates within the material arms.