כל זמן שתפילין בראשו או בזרועו אסור לישן בהם אפי' שינת אעראי אלא אם הניח עליה סודר ולא היתה בעמו אשה גישן בהם דשינת עראי וכיצד הוא עושה מניח ראשו הבין ברכיו והוא יושב וישן היו תפילין כרוכין בידו ומותר לישן בהם אפילו שינת קבע ואם אוחזן בידו ואינם כרוכים בידו זאסור לישן בהם אפי' שינת עראי: הגה ודוקא כשאוחזן בלא נרתקן אבל בנרתקן בכחל ענין שרי (ב"י בשם העיטור):
As long as the tefillin are upon one's head or upon one's arm, it is forbidden to sleep in them, even a brief nap (a light, dozing sleep). The exception is when he has placed a cloth over the head-tefillin and no woman is together with him — in that case he may take a brief nap while wearing them. And how does he do this? He sits, places his head down between his knees, and sleeps in that position (so that he will not slip into a deep sleep). If the tefillin were wound around his hand, he is permitted to sleep in them even a fixed sleep (a full, sound sleep). But if he merely holds them in his hand and they are not wound around it, he may not sleep in them even a brief nap. The Rema adds: This restriction applies specifically when he holds them without their case. But when they are in their case, it is permitted in any manner (Beis Yosef in the name of the Ittur).
ס״ק אעראי
(א) עראי - דגזרינן שמא יבוא להפיח בהם וע"י הנחת הסודר עליהן יזכור שיש תפילין עליו ולא יבוא להפיח:
(1) On the words "a brief nap": We decree against it out of concern that he may come to pass gas while wearing them (which would be a disgrace to the tefillin). And by placing the cloth over them, he will remember that the tefillin are upon him, and so he will not come to pass gas.
ס״ק בעמו אשה
(ב) עמו אשה - אבל אם אשתו עמו אסור גזירה שמא ישמש בהן:
(2) On the words "a woman with him": But if his wife is together with him, it is forbidden (even to take a brief nap), as a decree lest he engage in marital relations while wearing them.
ס״ק גישן בהם
(ג) ישן בהם - ולא חשיב היסח הדעת אלא כשהוא עומד בשחוק וקלות ראש אבל כשהוא עוסק במלאכתו ואומנתו ואין דעתו עליהן ממש אין זה נקרא היסח הדעת [אם לא שמטריד דעתו כ"כ לצרכי הגוף עד שלבבו פונה מי"ש מחמת טרדתו] וכן כשהוא ישן שוכח הבלי העולם. ומ"מ מצוה מן המובחר שיהא דעתו תמיד על התפילין ושלא יסיח דעתו מהן למשוך ולהרהר במחשבות רעות שמטעם זה חייב למשמש כל שעה שלא יסיח דעתו מהן [ב"ח] זולת בשעת התפלה והלימוד א"צ ליתן דעתו בהתפילין:
(3) On the words "he may sleep in them": Sleep here is permitted because it is not considered a distraction of the mind (which would be forbidden while wearing tefillin); such a distraction is only reckoned as one when a person stands in levity and lightheadedness. But when he is occupied with his work and his craft and his mind is not literally focused on the tefillin, this is not called a distraction of the mind. [This is so unless he burdens his mind so greatly with bodily needs that his heart turns away from the fear of Heaven on account of his preoccupation.] And likewise when he sleeps, he forgets the vanities of the world (and so this too is not a forbidden distraction). Even so, the choicest way to perform the mitzvah is that his mind be constantly upon the tefillin, and that he not divert his mind from them so as to be drawn after and dwell upon evil thoughts. For this reason he is obligated to touch them at every hour, so that he will not divert his mind from them [Bach]. The exception is during prayer and Torah study, when he need not consciously direct his mind to the tefillin (since he is already engaged in a sacred matter).
ס״ק דשינת עראי
(ד) שינת עראי - ואין שיעור לזה וי"א כדי הילוך ק' אמה והוא חלק ס"ז משעה בקירוב וכן פסק הגר"א בביאורו:
(4) On the words "a brief nap": There is no fixed measure for how long this brief nap may be. And some say its limit is the time it takes to walk one hundred cubits, which is approximately one sixty-seventh of an hour. And so the Vilna Gaon ruled in his commentary.
ס״ק הבין ברכיו
(ה) בין ברכיו - דאל"ה חיישינן שמא יבוא להשתקע בשינת קבע:
(5) On the words "between his knees": For if he did not do so (place his head between his knees while sitting), we would be concerned that he might come to sink into a fixed, deep sleep.
ס״ק ומותר לישן
(ו) מותר לישן - דלא חיישינן בזה להפחה כיון שאינם עליו:
(6) On the words "he is permitted to sleep": For in this case we are not concerned about passing gas, since the tefillin are not upon his body but only wound around his hand.
ס״ק זאסור לישן
(ז) אסור לישן - דחיישינן שמא יפלו מידו:
(7) On the words "it is forbidden to sleep": For we are concerned that they may fall from his hand (while he sleeps).
ס״ק חבכל ענין שרי
(ח) בכל ענין שרי - דאפילו אם יפלו על הקרקע אין חשש כ"כ ועיין בביאור הגר"א שכתב דדוקא אם הנרתק מחזיק טפח אז חשיב חציצה להפסיק בינו לקרקע:
(8) On the words "it is permitted in any manner": For even if they should fall to the ground while in their case, there is not so much concern. And see the commentary of the Vilna Gaon, who wrote that this leniency applies specifically if the case holds the space of a handbreadth, for then it is regarded as an interposition that separates between the tefillin and the ground.