I would say it depends on the use case
If you're developing apps for yourself (without the possibility of other people using your code), having them at top is also okay - quick preview of the implementation.
If you're developing SDKs/components for use elsewhere, the impl is generally more important than the UI, so it can be at the bottom.
But yeah, separate files also work as @Filip Wiesner says