Whether foreigners come to the mainland with Hong Kong ID cards free of visa or not depends on the situation:
1. If obtaining a Hong Kong permanent resident identity card and being a non Chinese national:
-Starting from July 10, 2024, these individuals can apply for a Mainland Travel Permit for Hong Kong and Macao Residents (non Chinese nationals). The travel permit issued with the approval of the entry and exit management agency is valid for 5 years. The holder can travel to and from the mainland multiple times within the validity period of the document, with each stay not exceeding 90 days. So to some extent, with compliance with relevant regulations and obtaining the permit, it is possible to achieve relatively convenient travel between the mainland, but it is not completely visa free, but a convenient way of travel similar to visa free.
2. If only obtaining a Hong Kong resident identity card (non permanent residence) regardless of whether they are Chinese citizens:
-Not enjoying the above-mentioned convenience policies, one needs to apply for the corresponding visa based on their nationality and relevant visa policies to enter the mainland.
The general policy for foreigners to come to the mainland with Hong Kong identity cards has specific conditions and regulations, and visa exemption cannot be generalized.