I’m currently using const prefersDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches; but it doesn’t take into consideration users that use a light system with a dark website.

EDIT: Solved with the following:

const element = document.getElementById("app");
const themeVariant = element.getAttribute("data-bs-theme");
if (themeVariant === "light") {
    var primaryBackground = "#f0f0f0";
} else {
    var primaryBackground = "#121317";
}