Tantrums happen for two basic reasons.
They start when toddlers are either in an environment where something has overloaded them so much that they can't cope with or they have become aware that they can influence your decisions by their interactions with you and can't cope with the emotions they feel when their efforts to get you to do something aren't working.
The second type usually happens if your response to the first teaches them that they can make you change your mind by losing it.
They are all best dealt with by maintaining a reassuring, calm, quiet presence. Children in true overload meltdown aren't usually good at processing language so suggestions, compromises and promises of rewards and punishments aren't worth your breath. Some children respond to being held, some hate it so you need to work out what helps your child.
If you saying they can have what they want stops the tantrum in its tracks, that should tell you something.
Give them time to come down from the state of total loss of control while staying close and making sure they feel as safe as possible. Once they are calmer, acknowledge their upset and suggest ways to move on. Remember that it's very easy to trigger another meltdown at this stage so don't bother with recriminations. Just focus on the next step.
If they are old enough you can talk later about the emotions they experienced and how else they could have expressed them.
Whatever you do, don't try to avoid a threatened tantrum by changing your mind and giving your child the thing they are kicking off to get. That is the best way to reinforce this behaviour and guarantee you will be dealing with tantrums for years, not months.
I used to watch a friend of mine give in to her toddler to prevent him having tantrums. He's now 12 and still having them to get what he wants and it's not pretty. It's an awful lot easier to stand your ground and be calm and firm with a two year old.