The term for the smallest meaningful unit of grammar in a language is a morpheme.
A morpheme may be a complete word or only part of a word. “Book” is a free morpheme because it can stand alone, while the plural ending “-s” in “books” is a bound morpheme because it must attach to another form. In “unhappy,” “un-” modifies the meaning of “happy”; in “walked,” “-ed” marks past tense.
Morphemes are studied in morphology, the branch of linguistics concerned with word structure. A single word can contain several morphemes: “rewriters” can be analyzed as re- + write + -er + -s, with each part contributing meaning or grammatical information.
A morpheme is not the same as a phoneme, which is a smallest sound unit and has no meaning by itself. Nor is it necessarily the same as a syllable: “cats” has one syllable but two morphemes, cat + -s. Linguists sometimes debate the boundaries of morphemes in complex or irregular forms.