import { createContextId, useContextProvider, useContext } from '@builder.io/qwik';
// 1. Create the ID
export const ThemeContext = createContextId<Signal<string>>('docs.theme-context');
// 2. Provide the value in a parent component
export default component$(() => {
const theme = useSignal('dark');
useContextProvider(ThemeContext, theme);
return <Child />;
});
// 3. Consume the value in a child component
const Child = component$(() => {
const theme = useContext(ThemeContext);
return <div>Theme is {theme.value}</div>;
});