In earlier days of dark mode, when very few sites supported it, when operating system did not support dark mode, every site had to rely on a toggle on the site itself to allow visitors to switch between dark and light modes.
Since then, since operating systems have started supporting dark mode, since CSS spec has standardized a way to discover dark mode user preference etc, it has kind of become anti patter to give the toggle. Now a site should silently switch to the mode that visitors prefer, and the dark mode toggle is only a escape hatch in case the implementation of dark mode is somehow not great.
If the operating system supports dark mode, user has told their OS that they indeed prefer dark mode, browser has told your site the user prefers dark mode, but user is compelled to switch to light mode for your site, it probably means you have done some mistake in your dark mode implementation, it may not be optimized in dark mode, some element may not be readable etc. A dark mode toggle soon may become part of developer tools for developers to see how their site looks like in different modes while they are developing the site.
Further Operation Systems today support changing dark mode preference based on time of day, and soon may do it based on ambient light conditions and so on. So relying on operating system dark mode hint is truly superior overall, as a future looking strategy.
Since currently the state of art has not matured enough, future is here but is not evenly distributed yet, it is still a recommendation to give dark mode switcher.
But the dark mode switcher should be “three state”, “user wants dark mode”, “user wants light mode”, and “user wants you to follow whatever their operating system is telling you about their dark mode preference”. Many sites give you two state logic, a toggle button that switches between a sun and moon icons. This two state switcher should be considered an anti pattern.
This kind of UI is preferred today: