A Svelte 5 component that overlays invisible buttons on a Ouija board image so users can select letters, numbers, and words (YES, NO, GOOD BYE). It is useful for novelty text input and not much else.
src/OuijaInput.svelte: reusable input componentsrc/App.svelte: minimal local app usageexamples/DemoApp.svelte: demo that maps word buttons to actions
npm install
npm run devnpm run demoThis opens examples/demo.html, which mounts examples/DemoApp.svelte.
Use bind:value for the current text and onSelect to react to board button presses.
<script lang="ts">
import OuijaInput from './OuijaInput.svelte';
let value = $state('');
type SelectDetail = { label: string; kind: 'letter' | 'number' | 'word' };
function submitMessage() {
console.log('submit', value);
}
function clearMessage() {
value = '';
}
function backspace() {
value = value.slice(0, -1);
}
function handleSelect(detail: SelectDetail) {
if (detail.kind !== 'word') return;
if (detail.label === 'YES') submitMessage();
if (detail.label === 'NO') backspace();
if (detail.label === 'GOOD BYE') clearMessage();
}
</script>
<OuijaInput bind:value onSelect={handleSelect} />boardImageSrc?: stringpath to board imageboardImageAlt?: stringalt text for the board imagevalue?: stringcurrent value (supportsbind:value)showWordButtons?: booleanshow or hideYES,NO,GOOD BYEshowLetterButtons?: booleanshow or hide letter buttonsshowNumberButtons?: booleanshow or hide number buttonsonChange?: (value: string) => voidcallback when value changesonSelect?: (detail: { label: string; kind: 'letter' | 'number' | 'word' }) => voidcallback when any board button is selected