Biological dyes work by adhering to various biological parts. Different dyes adhere to the different constituents of the cellular membranes, other attach to the proteins, carbohydrates, or lipids.
Some dyes are specific to the cell, and attach to the constituents of those specific cells only.