Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/svelte-devtools-theme-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/svelte-query-devtools': patch
---

Add theme option support to the floating devtools.
3 changes: 3 additions & 0 deletions docs/framework/svelte/devtools.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ Place the following code as high in your Svelte app as you can. The closer it is
- `shadowDOMTarget?: ShadowRoot`
- Default behavior will apply the devtool's styles to the head tag within the DOM.
- Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instead of within the head tag in the light DOM.
- `theme?: Theme`
- Defaults to `system`.
- Set this to change the theme of the devtools panel.
12 changes: 12 additions & 0 deletions packages/svelte-query-devtools/src/Devtools.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DevtoolsErrorType,
DevtoolsPosition,
TanstackQueryDevtools,
Theme,
} from '@tanstack/query-devtools'

interface DevtoolsOptions {
Expand Down Expand Up @@ -47,6 +48,11 @@
* Set this to true to hide disabled queries from the devtools panel.
*/
hideDisabledQueries?: boolean
/**
* Set this to 'light', 'dark', or 'system' to change the theme of the devtools panel.
* Defaults to 'system'.
*/
theme?: Theme
}

let {
Expand All @@ -58,6 +64,7 @@
styleNonce = undefined,
shadowDOMTarget = undefined,
hideDisabledQueries = false,
theme = 'system',
}: DevtoolsOptions = $props()

let ref: HTMLDivElement
Expand All @@ -80,6 +87,7 @@
styleNonce,
shadowDOMTarget,
hideDisabledQueries,
theme,
})

devtools.mount(ref)
Expand All @@ -102,6 +110,10 @@
$effect(() => {
devtools?.setErrorTypes(errorTypes)
})

$effect(() => {
devtools?.setTheme(theme)
})
}
</script>

Expand Down
Loading