A collection of value inspector components in the veins of svelte-json-tree
and react-json-view
.
It aims to be a valuable devtool for monitoring state and debugging, but should be usable for presenting data in any situation that calls for it.
* iterators and getters need to be manually iterated or activated to not trigger side effects
Install svelte-inspect-value
with your favourite package manager.
<script>
import Inspect, {InspectOptionsProvider, setGlobalInspectOptions} from 'svelte-inspect-value'
let name = $state('')
let age = $state(42)
// options provider function
setGlobalInspectOptions({ ... })
</script>
<!-- options provider component (alternative to function) -->
<InspectOptionsProvider options={{ theme: 'stereo', search: true, showTypes: false }}>
<!-- base component -->
<Inspect value={{ name, age }} />
<!-- base component variant that inspects any prop as individual values -->
<Inspect.Values {name} {age} />
<!-- fixed position panel -->
<Inspect.Panel values={{ name, age }}>
</InspectOptionsProvider>
These props are used for Inspect
and Inspect.Panel
values
- an object or array / iterable of values to be inspectedvalue
- a single value to be inspectedname
- a display name for value passed with value
-propThe props value
and name
will not be used if the values
-prop is set.
See the following pages in the documentation for a full overview of props:
Inspect
and Inspect.Panel
can be configured using any property of InspectOptions
by setting them as props directly on the component, but the simplest method is using the provider method shown in the example above, leaving you able to overwrite any global options using props if needed.
Inspect.Values
does not take any configuration props as any prop will simply be inspected, so the provider method is recommended. See the documentation on how to configure Inspect.Values
without using providers.
svelte-inspect