Hematoxylin is extracted from the heartwood of the logwood tree, Haematoxylum campechianum. It is not itself the dye: it must be oxidized to hematein, either slowly in air or quickly with an oxidant such as sodium iodate. Hematein then needs a mordant, usually aluminum, to form a positively charged dye-metal complex that binds the phosphate groups of nucleic acids, which is why chromatin stains strongly.
Freshly applied, the color is reddish purple. A brief alkaline rinse, the bluing step, turns it the familiar blue. Formulations are progressive, applied until the right depth is reached (Mayer's, for example), or regressive, overstained and then partly removed with dilute acid (Harris's, for example).