useTheme
- Category:
Composables
- Relate:
onThemeChange
getTheme
- Dependencies:
@lark-base-open/js-sdk
- Last Changed: 5 months ago
Notice
This function needs to use in Base, please use this website as a plugin in a Base to see the demo.
Demo
Show demo code
vue
<script setup lang="ts">
import { useTheme } from "@qww0302/use-bitable"
const themeMode = useTheme({
onChanged: (mode) => {
// console.log("Theme changed to", mode)
document.querySelector("html")?.setAttribute("class", mode.toLowerCase())
}
})
</script>
<template>
<div class="tip custom-block">
<p class="custom-block-title">
TIP
</p>
<p>Change the theme of <code>Bitable</code></p>
</div>
<p>Theme: {{ themeMode }}</p>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Usage
useTheme
is a responsive Bitable
theme, which listens to the theme changes of Bitable
and updates in real time.
TIP
Since the API
of Bitable
does not support plugins to modify the theme, useTheme
returns a read-only ref
here, which is not modifiable.
ts
import { useTheme } from "@qww0302/use-bitable"
const themeMode = useTheme({
onChanged: (mode) => {
// Do something when theme mode changed
}
})
1
2
3
4
5
6
7
2
3
4
5
6
7
Type Declarations
ts
import { ThemeModeType } from "@lark-base-open/js-sdk"
export interface useThemeOptions {
onChanged?: (theme: ThemeModeType) => void
}
/**
* Reactive bitable theme mode
*
* 响应式的bitable主题模式
*
* @param options
* @returns
*/
export declare function useTheme(
options?: useThemeOptions,
): import("vue").ComputedRef<ThemeModeType>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15