The mechanism of retractable needles varies between different brands and designs, but the general principle involves an automatic retraction of the needle into the syringe or a sheath after the injection is given. This can be activated by a button or a spring-loaded mechanism. The retraction is typically quick and efficient, ensuring that the healthcare worker's hands do not come into contact with the needle.