The Prophet ﷺ used to observe seclusion for ten days every Ramadan. In the year he passed away, he observed seclusion for twenty days.
كان النبي ﷺ يعتكف في كل رمضان عشرة أيام، فلما كان العام الذي قبض فيه اعتكف عشرين يوما.
Bukhari reported it in the book of itikaf (2044), from Abdullah bin Abu Shayba, who said, Abu Bakr (that is, Ibn Ayyash) narrated to us, from Abu Husayn (that is, Uthman bin Aasim), from Abu Salih, from Abu Hurairah, who said (and then he mentioned it).