The person observing I`tikaf may be visited by his family in the mosque
باب مَا جَاءَ فِي الْمُعْتَكِفِ يَزُورُهُ أَهْلُهُ فِي الْمَسْجِدِ
Sunan Ibn Majah, Book of Fasting(view book)
Sunan Ibn Majah 1779
It was narrated from Safiyyah bint Huyai, the wife of the Prophet ﷺ, that she came to visit the Messenger of Allah ﷺ when he was in I’tikaf during the last ten days of the month of Ramadan. She spoke with him for a while during the evening, then she stood up to go back. The Messenger of Allah ﷺ got up to take her home. When she reached the door of the mosque that was by the home of Umm Salamah, the wife of the Prophet ﷺ, two men from among the Ansar passed by them. They greeted the Messenger of Allah ﷺ with peace, then went away. The Messenger of Allah ﷺ said:
“Take it easy, she is Safiyyah bint Huyai.” They said: “Glorious is Allah, O Messenger of Allah!” And they were very upset by that (i.e., that he thought they may have some doubts). The Messenger of Allah ﷺ said: “The Satan flows through the son of Adam like blood, and I was afraid that he might cast some doubt into your hearts.”
حَدَّثَنَا إِبْرَاهِيمُ بْنُ الْمُنْذِرِ الْحِزَامِيُّ، حَدَّثَنَا عُمَرُ بْنُ عُثْمَانَ بْنِ عُمَرَ بْنِ مُوسَى بْنِ عُبَيْدِ اللَّهِ بْنِ مَعْمَرٍ، عَنْ أَبِيهِ، عَنِ ابْنِ شِهَابٍ، أَخْبَرَنِي عَلِيُّ بْنُ الْحُسَيْنِ، عَنْ صَفِيَّةَ بِنْتِ حُيَىٍّ، زَوْجِ النَّبِيِّ ﷺ أَنَّهَا جَاءَتْ إِلَى رَسُولِ اللَّهِ ﷺ تَزُورُهُ وَهُوَ مُعْتَكِفٌ فِي الْمَسْجِدِ فِي الْعَشْرِ الأَوَاخِرِ مِنْ شَهْرِ رَمَضَانَ فَتَحَدَّثَتْ عِنْدَهُ سَاعَةً مِنَ الْعِشَاءِ ثُمَّ قَامَتْ تَنْقَلِبُ فَقَامَ مَعَهَا رَسُولُ اللَّهِ ﷺ يَقْلِبُهَا حَتَّى إِذَا بَلَغَتْ بَابَ الْمَسْجِدِ الَّذِي كَانَ عِنْدَ مَسْكَنِ أُمِّ سَلَمَةَ زَوْجِ النَّبِيِّ ﷺ مَرَّ بِهِمَا رَجُلاَنِ مِنَ الأَنْصَارِ فَسَلَّمَا عَلَى رَسُولِ اللَّهِ ﷺ ثُمَّ نَفَذَا فَقَالَ لَهُمَا رَسُولُ اللَّهِ ﷺ " عَلَى رِسْلِكُمَا إِنَّهَا صَفِيَّةُ بِنْتُ حُيَىٍّ " . قَالاَ سُبْحَانَ اللَّهِ يَا رَسُولَ اللَّهِ وَكَبُرَ عَلَيْهِمَا ذَلِكَ فَقَالَ رَسُولُ اللَّهِ ﷺ " إِنَّ الشَّيْطَانَ يَجْرِي مِنِ ابْنِ آدَمَ مَجْرَى الدَّمِ وَإِنِّي خَشِيتُ أَنْ يَقْذِفَ فِي قُلُوبِكُمَا شَيْئًا " .