1. Check whether your iPhone is overheating. The iPhone may heat up a bit while charging. To extend battery life, if the battery becomes overheated, the software may limit charging when the charge exceeds 80%. When the temperature drops, the iPhone charges again. Try moving your iPhone and charger to a cooler location.
2. Replace the charger and charging cable
This may be a battery problem, it is best to ask a professional to look at it