The cheese and onion toastie is a hot, sealed sandwich, and the seal is what separates it from the cold cheese and onion it shares an ingredient list with. Buttered on the outside, filled with cheese and onion, and pressed in a hot iron or under a grill, the bread crisps to a hard shell while the cheese inside turns molten and the edges weld shut. That fused border is the entire engineering: it traps a soft, hot, partly liquid centre inside a crisp case, and it keeps the melted filling and the onion's released juice from running out when the toastie is cut. A toastie that has not sealed is just warm cheese on toast with a soft onion in it, which is a worse and a different thing.
The craft is heat timing made harder by the onion. The cheese has to melt before the bread scorches, so a strong Cheddar that flows rather than splits is used and the heat is steady rather than fierce. The onion is the complication a plain cheese toastie does not have: raw onion put straight into the press is still sharp and crunchy when the cheese has gone molten, and worse, it releases water as it heats that the seal then has to contain. The good move is to slice it thin and soften it ahead of time, sweated in a pan until it is sweet and most of its moisture is gone, so it goes in as a mellow, low-water layer the seal can hold. The cheese load stays moderate because an overfilled toastie blows its weld and floods the iron. Butter, not oil, on the outside faces is what crisps and browns the shell evenly and gives the seal something to set against. The bread is plain and not too thick, so heat reaches the centre before the crust burns.
The variations stay inside the pressed-and-melted frame. Swapping in red onion or caramelising it harder pushes the whole thing sweeter; a slick of pickle or brown sauce inside adds a sharp note the heat rounds off; a different melting cheese changes the pull and the salt. The cold cheese and onion is the same pairing with the seal and the heat removed entirely. Each deserves its own article rather than being crowded in here.