Layering means placing one liquid on top of another so they do not mix. It looks like a trick and it is straightforward physics, and the same technique produces the aromatic floats used in several classic drinks.
What determines density
Two things pull in opposite directions.
Sugar increases density. A sweet liqueur is heavier than a dry one and will sink.
Alcohol decreases density. A high-strength spirit is lighter than a low-strength one and will float.
Sugar is the stronger effect in most cases, which is why syrupy liqueurs sit at the bottom and spirits sit on top.
So the order runs from sweetest and lowest in alcohol at the bottom to driest and strongest at the top.
The technique
Pour the densest liquid into the glass first.
Hold a bar spoon just above the surface with the back facing up, touching the inside of the glass.
Pour the next liquid slowly over the back of the spoon, so it spreads across the curved surface and settles gently rather than plunging through.
Pour slowly. Speed is what breaks a layer.
Repeat for each layer, working from densest to lightest.
Practical points
A cold glass and cold liquids layer more cleanly, since temperature differences affect density.
A narrow glass is easier than a wide one, since there is less surface for the incoming liquid to disturb.
Anything with bubbles will not layer, since the gas carries liquid upwards.
Layers do not last indefinitely. Diffusion mixes them over minutes to hours, faster if the drink is disturbed.
The floats worth knowing
Layering as spectacle is one thing; layering as technique is more useful.
A New York sour floats red wine on a whiskey sour. The base is sweetened and diluted, so it is denser than the wine, which stays on top. The tannin arrives gradually as you drink through it.
A penicillin floats a peated Scotch on a honey and ginger sour. The whisky is stronger and drier than the base, so it floats, and the smoke reaches the nose without dominating the liquid.
A dark and stormy floats dark rum on ginger beer.
A Queen's Park Swizzle has bitters dashed on top of crushed ice, which bleed downwards.
In each case the point is the same: an ingredient too assertive to mix in becomes an aromatic layer instead, and the drink changes as you work through it.
Troubleshooting
If a float sinks, the base was not sweet or dilute enough. Adding a little more syrup to the base solves it.
If it pours through the layer, the pour was too fast or the spoon was held too high.
If the layers merge immediately, the densities are too close to separate.
The egg white advantage
A foam gives a float something solid to sit on, which makes layering considerably easier.
This is why a New York sour with egg white in the base holds its wine layer more reliably than one without.
The same applies to bitters dropped on a foam, which sit on the surface indefinitely rather than sinking.
Whether it is worth doing
As decoration, occasionally.
As technique, genuinely. The aromatic float is a real solution to a real problem, which is how to include something powerful without letting it take over.
Once you understand it, it becomes a tool rather than a trick, and it is worth trying on any drink where one ingredient keeps dominating.
Testing a float first
If you are unsure whether something will float, try it in a glass of water.
Anything that floats on water at a given sugar level will generally float on a similarly sweetened drink, which saves ruining a cocktail to find out.
How long layers last
Minutes rather than hours, and less if the glass is disturbed or carried.
Layered drinks should be made immediately before serving and not moved far.
Whether to stir it in
A matter for the drinker. Stirring gives a uniform drink; leaving it layered gives one that changes from first sip to last.
Most people who try both prefer it layered, and it costs nothing to find out.