GitHub

File tree

  • src/runtime

    • components/color-mode

    • vue/components/color-mode

Original file line numberDiff line numberDiff line change

@@ -27,9 +27,6 @@ const props = withDefaults(defineProps<ColorModeButtonProps>(), {

2727

color: 'neutral',

2828

variant: 'ghost'

2929

})

30-

defineSlots<{

31-

fallback(props?: {}): any

32-

}>()

3330
3431

const { t } = useLocale()

3532

const colorMode = useColorMode()

@@ -48,21 +45,17 @@ const isDark = computed({

4845

</script>

4946
5047

<template>

51-

<ClientOnly v-if="!colorMode?.forced">

52-

<UButton

53-

v-bind="{

54-

...buttonProps,

55-

'icon': props.icon || (isDark ? appConfig.ui.icons.dark : appConfig.ui.icons.light),

56-

'aria-label': isDark ? t('colorMode.switchToLight') : t('colorMode.switchToDark'),

57-

...$attrs

58-

}"

59-

@click="isDark = !isDark"

60-

/>

61-
62-

<template #fallback>

63-

<slot name="fallback">

64-

<div class="size-8" />

65-

</slot>

48+

<UButton

49+

v-bind="{

50+

...buttonProps,

51+

'aria-label': isDark ? t('colorMode.switchToLight') : t('colorMode.switchToDark'),

52+

...$attrs

53+

}"

54+

@click="isDark = !isDark"

55+

>

56+

<template #leading="{ ui }">

57+

<UIcon :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" class="hidden dark:inline" :name="appConfig.ui.icons.dark" />

58+

<UIcon :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" class="inline dark:hidden" :name="appConfig.ui.icons.light" />

6659

</template>

67-

</ClientOnly>

60+

</UButton>

6861

</template>

Read the original on github.com ↗