No, ‘if’ is not a preposition. It is classified as a conjunction.
To understand this better, we need to look at the function of ‘if’ in a sentence. A conjunction is a word that connects clauses or sentences. In this case, ‘if’ is used to introduce a conditional clause, which presents a condition that must be met for the main clause to be true. For example, in the sentence, ‘If it rains, we will stay indoors,’ ‘if’ connects the conditional idea of raining with the action of staying indoors.
On the other hand, prepositions are words that show a relationship between a noun (or pronoun) and other words in a sentence, indicating direction, place, or time, such as ‘in,’ ‘on,’ and ‘at.’ Since ‘if’ does not perform this role, it clearly does not fit the definition of a preposition.