We're planning to create a headless UI component to have the logic and functionality for the actual language selector element. The UI component will then be built on top of this headless component. This approach allow us to build different interfaces easily.
Here’s some exploration by @santhosh:
Demo: https://csb-2hd7s.netlify.app/
Code: https://codesandbox.io/s/renderless-language-selector-2hd7s
While we are still validating this approach, we will build a component into MediaWiki core and start using it in a couple of places where a language selector is needed inside MediaWiki.
We will review the possibility of moving the library out to a separate independent component.
Solution
Documentation for added components: https://www.mediawiki.org/wiki/Manual:LanguageSelector