Can't use Romex for extension cord!!
Romex (NM-B and UF-B) are made for wiring in the walls, that never moves. You may have noticed it is very stiff. That means it is solid or coarse stranded wire, and will not bend well. Instead of bending, it will metal-fatigue and strands will break. At that point it starts a fire from overheat or arcing.
You need a special type of cable called cordage. You're familiar with cordage; it's on every appliance. Note how it is flexible and tough. It has dozens of strands, like welding cable.
Cordage is a little different
Now, cordage is numbered differently. When we say /3 Romex, we really mean 4 wires. With cordage, /3 means 3 wires and one will be green ground. That's the stuff to use.
You only need #10 cordage since you are carrying <30A. There are a variety of cordage markings, such as SJOW or SJOOW. Skip the home store, go straight to the electrical supply house, both for the cordage, and also for the plugs and sockets that will go onto the cordage.
You won't like the price of #10 cordage, but you wouldn't have liked the price of #8 NM-B either.
It's perfectly legit to build an extension cord with 10/3 SJOOW cordage, a NEMA 14-30 plug on one end, and a NEMA 6-30 socket on the other. In these large sizes, most extension cords are home-built ("field assembled").
You use the white wire in the cordage for the other (red) hot. Pay close attention to the strain relief where the sheath (outer coating) is clamped into the plug. It needs to hold well.