Explain native styles
explainStyle creates a structured explanation for one export from a compiled
.css.ts module. The API is opt-in and lives at
@opsydyn/crumbs-css/devtools, so ordinary theme and styling imports do not
load the explanation implementation or Effect Schema.
Native inspector in use
Section titled “Native inspector in use”The opt-in native widget is introduced in Crumbs 1.3.0. Check the release status for publication; npm 1.2.0 does not include it. These are real SDK58 Simulator/emulator captures from our Storybook and Playground qualification.


Control metadata emission
Section titled “Control metadata emission”Metro development transforms include the __crumbsDev provenance sidecar by
default. Production transforms omit it. Set
transformer.nativeStyles.includeStyleExplanations to override either default:
const config = getDefaultConfig(__dirname)config.transformer = { ...config.transformer, nativeStyles: { ...config.transformer?.nativeStyles, includeStyleExplanations: false, },}
module.exports = withNativeStyles(config)Use false to disable metadata in development, or true to include it in a
production transform. Production inclusion adds provenance to emitted modules;
choose it only for a build that needs style explanations. Direct calls to
transformCssTsToStyleSheet use the same includeStyleExplanations option and
otherwise follow dev (or NODE_ENV when dev is omitted).
Explain an explicit export
Section titled “Explain an explicit export”Snapshot your trusted compiled module namespace and pass the exact export path.
Metro namespaces can expose accessor bindings; the explanation boundary accepts
own data properties and deliberately does not invoke arbitrary getters. Spreading
your known imported namespace explicitly reads those bindings. Keep the original
unresolved exports and metadata; do not pass the result of useThemedStyles.
Supply concrete
inputs instead of relying on ambient render state:
import { explainStyle, type StyleExplanationReport } from "@opsydyn/crumbs-css/devtools"import * as cardStyles from "./card.css"
const report: StyleExplanationReport = explainStyle({ module: { ...cardStyles }, exportPath: ["card"], current: { theme: activeTheme }, previous: { theme: previousTheme },})
const opacity = report.composition.properties.find(property => property.property === "opacity")console.log(opacity?.winner, opacity?.overridden)console.log(report.dependencies.changedTokens, report.transition)For recipe exports, pass the runtime selection in current.selection. Add a
condition snapshot in current.conditions when the style depends on native
conditions. Component recipe extensions are explicit and ordered; provide the
descriptors in current.extensions so the explanation uses the same extension
chain as the resolver:
const report = explainStyle({ module: { ...componentStyles }, exportPath: ["button"], current: { theme: activeTheme, selection: { tone: "brand", disabled: false }, conditions: currentConditions, extensions: [brandButtonExtension], },})previous is optional. Without it, transition.status is not-compared. With
it, the report compares the explicit snapshots and the compiled dependency
plan. A relevant token, selection, condition, or extension change can identify
affected export paths; an unrelated token change can be reported without
claiming that the style changed.
Read the report and its coverage
Section titled “Read the report and its coverage”The report separates the final resolved value from the decisions that produced
it. composition.properties records the winning declaration and overridden
declarations in source order, including authored and canonical properties for
native aliases. resolution.branches, conditions.decisions, and
conditions.expressionMatches show selected and rejected branches for recipes,
component recipes, Sprinkles, native conditions, and expressions.
Theme-token values retain their token identity and carry the value resolved
from the supplied theme. undefined and negative zero use explicit tagged
values. Unsupported values are represented as opaque values with a reason and
reduce coverage rather than being invoked or silently treated as ordinary
JSON.
Check coverage before relying on provenance:
completemeans the report has the captured metadata for this export.partialidentifies limitations such as compatibility-only metadata, opaque values, or a mismatch between style values and dependency metadata.unavailablewithmetadata-missingmeans the module did not contain a development sidecar.
The API explains only the supplied module, export path, and snapshots. It does
not inspect other files, observe React renders or cache hits, or read device
state. explainStyle returns ordinary typed data; Effect 4 Schema is an
internal validation boundary and is not part of the consumer call pattern.
Native widget (1.3.0+)
Section titled “Native widget (1.3.0+)”The widget is introduced at @opsydyn/crumbs-css/devtools/native in v1.3.0.
Version 1.2.0 includes the headless report API, but not this entry.
Keep all value imports of the widget and its probes in a separate development module. Conditional JSX around an unconditional import is insufficient to remove the dependency graph from production. For Metro, use this boundary:
// inspector.tsx — safe to import from application componentsimport type { ComponentType, ReactNode } from "react"
const development: typeof import("./inspector.dev") | null = __DEV__ ? require("./inspector.dev") : null
export const InspectorHost: ComponentType<{ children: ReactNode }> = development?.InspectorHost ?? (({ children }) => <>{children}</>)export const CardProbe = development?.CardProbe ?? (() => null)// inspector.dev.tsx — reached only in developmentimport type { ReactNode } from "react"import * as Clipboard from "expo-clipboard"import { useTheme } from "@opsydyn/crumbs-css/theme/core"import { CrumbsDevtoolsProvider, CrumbsDevtoolsWidget, useCrumbsInspectorTarget,} from "@opsydyn/crumbs-css/devtools/native"import * as cardStyles from "./card.css"
export function InspectorHost({ children }: { children: ReactNode }) { return ( <CrumbsDevtoolsProvider> {children} <CrumbsDevtoolsWidget placement="bottom-right" insets={{ bottom: 32, right: 16 }} copyText={async text => { await Clipboard.setStringAsync(text) }} /> </CrumbsDevtoolsProvider> )}
export function CardProbe() { const theme = useTheme() useCrumbsInspectorTarget({ label: "Card", exportPath: ["card"], getInput: () => ({ module: { ...cardStyles }, exportPath: ["card"], current: { theme }, }), }) return null}Wrap your app in InspectorHost. Mount CardProbe inside the same ThemeProvider
scope as the card. Pass current recipe selections, conditions and extension
chains to current when used. The getter must describe committed inputs; do not
mutate them behind React’s back. Separate probes can share labels: identities are
per mounted instance. Registration outside the provider throws a setup error.
Expo Clipboard is an app dependency, not a Crumbs dependency. Install it with
npx expo install expo-clipboard; rebuild a development client if it lacks that
native module. Other hosts can supply their own asynchronous clipboard adapter.
Insets are logical units. Include your host’s safe-area values; the widget does not add a safe-area library to your application. The launcher and actions have minimum 44-unit targets. Native back, Close and web Escape dismiss the panel.
Capture, refresh and copy
Section titled “Capture, refresh and copy”The panel explains only the supplied Crumbs inputs. It does not pick elements, read the native rendered style, sample pressed/animated state or observe the whole application. Explicit selection and Refresh run the explanation; committed input changes mark the current report stale. Closing clears selection/report; unmounting releases the registration. A provider admits up to 200 targets and retains at most one report. After overflow, a conservative warning remains until the provider is remounted; rejected probes retry on their next commit. Closed updates do not call getters or explanation.
Preview prepares the exact text subsequently passed to copyText. Reports can
contain private style values or source paths. An optional redactReport(capture)
callback returns the JSON value to preview/copy; it does not alter the on-screen
explanation. Throwing redactors, accessors, cycles, non-JSON values and payloads
over 256 KiB of UTF-8 are rejected before clipboard writes. Copy failures remain
recoverable. Stale reports and late clipboard completions cannot become a fresh
successful capture. Review the preview before sharing it.
Coverage is explicit: missing metadata is unavailable, and unsupported or
compatibility-only evidence is partial. Disabling development metadata using
the option above does not manufacture complete provenance. Default production
exports exclude both widget implementation (with this import boundary) and
provenance. Opting production into metadata changes that guarantee.