It depends on what will that variable AC feed.
If very little current (a few mA) a rheostat (heavy duty wirewound potentiometer) will do, but for any significant load, a transformer is better.
IMPORTANT: A Variac does NOT isolate you from Mains, so secondary is still very dangerous/deadly (pick one), **even if you set it to low voltage**
Now through a 120 to 24 Vac *isolating* transformer as shown, it becomes safe.
If very little current (a few mA) a rheostat (heavy duty wirewound potentiometer) will do, but for any significant load, a transformer is better.
IMPORTANT: A Variac does NOT isolate you from Mains, so secondary is still very dangerous/deadly (pick one), **even if you set it to low voltage**
Now through a 120 to 24 Vac *isolating* transformer as shown, it becomes safe.