Preheat the oven to 190C/170C fan/Gas 5. Grease an ovenproof dish with a little butter.
Melt the butter in a saucepan over medium heat. Add the flour and stir for 1 minute to make a roux.
Gradually whisk in the milk, stirring constantly to avoid lumps. Cook for 3-4 minutes until you have a smooth, thick sauce. Remove from the heat and stir in two-thirds of the cheese, the mustard and some salt and pepper.
Layer half the sliced potatoes, leeks and onion in the dish. Pour over half the cheese sauce. Repeat with the remaining vegetables and sauce.
Scatter the remaining cheese on top and add a sprinkle of herbs if using. Cover with foil and bake for 25 minutes. Remove the foil and bake for another 15 minutes until the top is golden and the potatoes are tender.
Let it rest for 5 minutes before serving - it will be molten if you cut it straight away.