Skip to content

Commit 50c9758

Browse files
mrcegobrc-dd
andauthored
fix(theme/i18n): support customizing dark mode switch titles (#3311)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent bb64ecb commit 50c9758

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Diff for: docs/reference/default-theme-config.md

+14
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,20 @@ export interface DocFooter {
406406

407407
Can be used to customize the dark mode switch label. This label is only displayed in the mobile view.
408408

409+
## lightModeSwitchTitle
410+
411+
- Type: `string`
412+
- Default: `Switch to light theme`
413+
414+
Can be used to customize the light mode switch title that appears on hovering.
415+
416+
## darkModeSwitchTitle
417+
418+
- Type: `string`
419+
- Default: `Switch to dark theme`
420+
421+
Can be used to customize the dark mode switch title that appears on hovering.
422+
409423
## sidebarMenuLabel
410424

411425
- Type: `string`

Diff for: src/client/theme-default/components/VPSwitchAppearance.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import VPSwitch from './VPSwitch.vue'
55
import VPIconMoon from './icons/VPIconMoon.vue'
66
import VPIconSun from './icons/VPIconSun.vue'
77
8-
const { isDark } = useData()
8+
const { isDark, theme } = useData()
99
1010
const toggleAppearance = inject('toggle-appearance', () => {
1111
isDark.value = !isDark.value
1212
})
1313
1414
const switchTitle = computed(() => {
15-
return isDark.value ? 'Switch to light theme' : 'Switch to dark theme'
15+
return isDark.value
16+
? theme.value.lightModeSwitchTitle || 'Switch to light theme'
17+
: theme.value.darkModeSwitchTitle || 'Switch to dark theme'
1618
})
1719
</script>
1820

Diff for: types/default-theme.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ export namespace DefaultTheme {
9696
*/
9797
darkModeSwitchLabel?: string
9898

99+
/**
100+
* @default 'Switch to light theme'
101+
*/
102+
lightModeSwitchTitle?: string
103+
104+
/**
105+
* @default 'Switch to dark theme'
106+
*/
107+
darkModeSwitchTitle?: string
108+
99109
/**
100110
* @default 'Menu'
101111
*/

0 commit comments

Comments
 (0)