I have a wall light that has 18 gauge wire. I want to hard wire this lamp in and put it on a dimmer switch that calls for 14-2 or 12-2 wire. Can this be done? I tried to hook it up but it keeps tripping the breaker.
After a comment I think I understand your question more clearly.
Firstly, if there is 18 gauge wiring in your house then this is likely not to code and you might consider having an electrician take a look. Too small of a conductor can be a fire hazard! Lets hope you are referring to the fixture wiring.
With regards to cabel labeling, the -2 just refers to how many conductors are in the cable (14-2 actually has 3 - a hot, neutral and ground. A 14-3 has 2 hots, neutral and ground).
Assuming the dimmer is rated for the load of the light, you can use the dimmer with the smaller conductor. Just be sure to use the screw terminals and not the push-in terminals (if it has these) as they will not hold the smaller conductor.
If the breaker is tripping it means you miswired it; likely you have shorted the hot to the neutral. You want the dimmer to be in-line with the hot and not across both wires. If you are in North America, the hot side of the plug is the smaller of the holes.
Some electronic dimmers also have a neutral on them so they can be powered independently of the light.
Where is the dimmer going to be located? Both the fixture and dimmer should be in junction boxes of some type and fed with either 14 or 12 AWG wire depending on the breaker/fuse capacity. The fixture is then wirenuted to the house wire in a box behind the fixture. The only place 18AWG wire should be located is in j-box the fixture is mounted to.
Did I miss something in the question??????