İtikâf is divided into three parts: wâjib, sunnah and mustahab.
1. Wajib İtikâf
If someone devotes himself to doing itikaf, this makes itikaf Wajib for him.
Devoting one's self to itikaf can be out of the result of saying either " For the consent of Allah, may i owe doing itikaf for three days.", or " If I get rid of this illness, if my patient gets healed or if I get this job, I will do itikaf for this many days." In this case, when what he awaits happens, it becomes vâjib on him that he enters itikaf for the days he devoted himself for. If he does not enter, he becomes a sinner because as stated in the verse; “O, you who believe! Be loyal to your conventions and fulfill them." [5/Mâide, 1.] As also our Prophet(sav) said : "Whoever makes a commitment to obey Allah, should he do his dedication and obey Allah." [Buhârî, İman, 28, 31.]
2. Sunnah İtikâf
It is sunnah to enter itikaf in the last 10 days of Ramadan
Because, as we have stated before, the Prophet (sav) did itikaf in the last ten days of each month of Ramadan, from the time the fast of Ramadan was made obligatory, until the end of his life.
3. Mustahab İtikâf
On other times, it is mustahab to do itikaf.
It is a must to fast during wajib itikaf. For that reason, devoted itikaf cannot be less than one day.
Sunnah itikaf is done while fasting as it is already during Ramadan
There is no certain time length to do the mustahab itikaf for, it can be done for a short amount of time aswell. Even a person who enters a masjid with the intention of Itikaf, is considered to be in itikaf during his stay in masjid and gets a reward of itikaf.