Theobromine, which is an alkaloid, is the toxic substance in chocolate.
But the dose makes the poison. It’s also toxic in humans but the lethal dose 50 (LD50, which is the dose at which 50% of people or animals will die) is much higher in humans, which is 1000 mg/kg of body weight, while in cats its 200 mg/kg in cats and 300 mg/kg in dogs.
Bear in mind that dogs and cats are smaller than humans, so that compounds the potential lethality.
Dark chocolate (85% cacao) has 810 mg per 100 g, so for a 70 kg adult human, you’d have to eat >7 kilograms of dark chocolate to get close to the LD50. But a small dog will get sick and potentially die from just one bar of dark chocolate. there is a calculator here: Chocolate Toxicity Meter | petMD .
I would say it’s best not to give them any. My dogs go crazy for chocolate so I usually give them a tiny sliver just to let them taste it. My dogs are 50 lbs each so I would have to give them more than one bar to kill them, but in any case I’m not risking it.