Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow multiple different color modes in addition to light|dark for themes #4471

Open
4 tasks done
michaelcozzolino opened this issue Jan 7, 2025 · 0 comments
Open
4 tasks done

Comments

@michaelcozzolino
Copy link

michaelcozzolino commented Jan 7, 2025

Is your feature request related to a problem? Please describe.

right now the appearance has the following type:

appearance?: boolean | 'dark' | 'force-dark' | 'force-auto' | (Omit<UseDarkOptions, 'initialValue'> & {
        initialValue?: 'dark';
    });

the Omit<UseDarkOptions, 'initialValue'> allows to have only valueDark and valueLight, but it does not allow me to have other modes different than dark/light such as custom mode created by the developer giving further color customisation to the theme: light|dark|luxury|business and so on.

Describe the solution you'd like

i would like to have the possibility to use multiple modes in addition to dark/light. so that the appearance type becomes something like:

interface Appearance<T extends string> {
    appearance?: boolean | 'dark' | 'force-dark' | 'force-auto' | (Omit<UseColorModeOptions<T>, 'initialValue'> & {
        initialValue?: 'dark';
    });
}

where T is a union type of color modes like 'light'|'dark'|'luxury'|'business' that the developer will specify

Describe alternatives you've considered

No response

Additional context

if this is not possible please provide a solution in the case where:

  1. I override the theme switcher with a custom theme switcher created by me containing different modes
  2. I still have to keep the appearance to be not false in the config.ts else the switcher will disappear

my current workaround is to use the vitepress-theme-appearance as storageKey in my custom component

 type AvailableTheme = 'light' | 'dark' | 'gourmet';

const theme = useColorMode<AvailableTheme>({
    attribute:  'data-theme',
    storageKey: 'vitepress-theme-appearance',
    modes:      {
        // custom colors
        light:   'light',
        dark:    'dark',
        gourmet: 'gourmet',
    },
    initialValue: 'dark',
});

that would be fine if the component would not be a part of a vue components package i am building. yeah, i could still pass the storageKey as props and let the developer handle it if needed, but it might not be the best option.

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant