You could look into "Patch Antenna" design.
Some theory here: http://www.antenna-theory.com/antennas/patches/antenna.php
however: manufacturing this yourself would be quite challenging I would imagine.
[edit due to comments]
Hi BT, it seems you asked a different question in the comments.
I guess the original question:
what types of directional antennas would be practical at a maximum length of 5mm, and what limitations are necessary with that constraint?
Would be answered by above reference to patch-antennas.
Now you are asking:
How are these used in mobile devices without being omnidirectional?
This can be broken up in two questions:
1) How are these used in mobile devices ?
2) without being omnidirectional ?
Answers are simple:
1) They are not used in mobile devices, or at least not main-stream, due to size of the patch itself (there are others derived from patch antenna design, already commented below)
2) They are directional. But this does not seem to hinder mobile technology. The cell towers seem to have enough directivity/gain/coverage/power to reliably build connections even when the mobile device has a "somewhat directional" antenna.