I've noticed that a few of my professors have written their own textbooks, but they only did so after they had already published many research articles and presumably become tenured at my university. For this reason, I'm wondering (in general), does writing textbooks contribute to acquiring tenure at a university, or are textbooks just considered the "icing on the cake" of the professor's published research?
I have spoken with a few people who have written textbooks. The universal advice they have given is never write a textbook until after you have received tenure.
In general, you get very little or no credit for writing a textbook, as it doesn't really help in any of the major "checkboxes" for tenure—research, teaching, and service. In addition, the time that you spend working on the textbook can generally be put to better use in writing grant proposals or working on peer-reviewed manuscripts.
I know from personal experience, when I was a graduate student, that there was an assistant professor in my department who spent all of his time working on a textbook. He let his research languish, and ended up with a textbook but no promotion to associate professor.
A textbook would almost certainly be viewed positively for tenure. However, people don't usually write textbooks before they have tenure, for at least the following two reasons:
It is a huge undertaking. You have to expect it to take a year or more to get it all right and finished, during which you will likely not have time to publish much else. There may also be another 1-2 year delay before the book is actually accepted and in print (i.e., it may not happen in time for the tenure evaluation). From the perspective of a tenure committee, a single (possibly unpublished) textbook rarely outweighs the smaller number of publications you will be able to show. For this reason, older colleagues will almost certainly discourage untenured professors from writing textbooks.
Writing a good textbook benefits hugely from many years of teaching experience, and in particular teaching the class for which the book is intended many times. Untenured professors rarely have the kind of experience that makes it worthwhile writing a book that actually shows their thoughts on how teaching this course works best.