There is no such thing as an electrical fire extinguisher, because electricity is not a fuel. What is burning is plastic, insulation or something nearby, and the electricity is the ignition source and the hazard to the person holding the extinguisher. The question is therefore which agents have been tested as safe to use near live equipment.
Isolate first if you safely can
Switching off or unplugging removes the shock hazard and often removes the source of heat, which can be the whole answer for a small appliance fire. If isolation is safe and quick, do it before reaching for anything. If it means crossing the fire, or if the switchgear itself is involved, leave it, get out and let the fire service deal with it.
Carbon dioxide is the usual choice
Carbon dioxide leaves no residue, will not conduct back to the user in the way a water jet can, and does not destroy the equipment it is used on. That is why it is the standard extinguisher beside distribution boards, server racks and laboratory equipment. It is not rated class A, so a carbon dioxide extinguisher alone is not adequate provision for a room that also contains paper and furniture.
Dielectrically tested water and foam
Some water and foam extinguishers are tested against a standard dielectric test and carry a statement on the label about use near live electrical equipment, usually with a minimum distance. That makes them a practical single extinguisher in an office where the realistic fire is a bin or a laptop. Where the label says nothing about it, treat the extinguisher as unsuitable near live equipment.
Dry powder outdoors and in vehicles
ABC powder is electrically safe and is the normal provision for vehicles, forecourts and external plant where residue and visibility matter less. Inside an occupied building it is discouraged for the same reasons as always: a discharge blinds the room, irritates the airway and leaves a corrosive residue that will finish off any electronics the fire did not.
Questions people ask about fire extinguishers for electrical fires
What extinguisher would you use on an electrical fire?
Carbon dioxide is the usual answer. Some water and foam extinguishers are dielectrically tested and say so on the label. Powder is electrically safe but discouraged indoors.
Is there an electrical fire class?
No. The UK classes run A, B, C, D and F with no class E, because electricity is an ignition source rather than a fuel. Extinguishers are instead tested for safe use near live equipment.
Should I switch the power off first?
Yes, if it is safe and quick and does not mean crossing the fire. Isolation removes the shock hazard and frequently removes the heat source as well.