I learned that TailwindCSS automatically removes the dark class from the bundled CSS if it is not used in any className attribute in JSX. To force TailwindCSS to bundle the dark class, I added the following to my tailwind.config.ts:
safelist: ['dark']