A Companion named Hanzala once told Abu Bakr that he had become a hypocrite, since when they were with the Prophet ﷺ they felt as though they could see Paradise and Hell, and when they went home to their families and work they forgot much. The Prophet ﷺ told him: if you stayed as you are with me, the angels would shake your hands, 'but, Hanzala, there is an hour for this and an hour for that.' The Quran also asks the believers if it is not time for their hearts to be humbled to the remembrance of Allah, so even believers are reminded that hearts can become hard through time and heedlessness.
What helps is a steady routine rather than big bursts. The Prophet ﷺ said that the deeds most beloved to Allah are the most regular, even if small. A person can keep praying on time, even briefly; read a small part of the Quran with a translation every day; ask Allah by name for guidance; ask forgiveness for what has made the heart heavy; spend time with people who remind them of Allah; and give to those in need. The Quran says that Allah is near and answers the caller, so even a dry prayer is heard.
It also helps to ask what lies behind the distance. If a particular question has shaken your faith, name it, and study it instead of avoiding it. If a person or a community hurt you, remember that Muslims are imperfect, and that this is not the same as the truth of the message. Exhaustion, stress or low mood can also dull any feeling, spiritual or otherwise, and a doctor can help. And if you feel that you have walked away entirely, the Quran's message is that Allah's mercy is open to everyone who returns: 'Do not despair of the mercy of Allah.'