Skip to content

TypeScript

The package ships full type definitions and exports the following types:

  • PhantomUi – the Web Component class
  • PhantomUiAttributes – props interface for JSX type augmentation
  • SolidPhantomUiAttributes – props interface with attr: prefixed variants for Solid
  • ElementInfo – internal type for measured DOM elements

Nothing runs on install: the library has no postinstall hook, so your source is never modified unless you ask for it. The bundled init command detects your project setup and handles two things:

  • JSX type declarations: For React, Solid, and Qwik, it generates a phantom-ui.d.ts in your src/ directory.
  • SSR pre-hydration CSS: For Next.js, Nuxt, SvelteKit, Remix, and Qwik, it adds import "@aejkatappaja/phantom-ui/ssr.css" to your layout file to prevent content flash before hydration (see SSR Frameworks).

Run it once from your project root:

npx @aejkatappaja/phantom-ui init

Vue and Svelte read the HTMLElementTagNameMap augmentation from the main type declarations. No extra file needed.

Angular uses CUSTOM_ELEMENTS_SCHEMA which bypasses type checking for custom elements.

import type { PhantomUiAttributes } from "@aejkatappaja/phantom-ui";
declare module "react/jsx-runtime" {
export namespace JSX {
interface IntrinsicElements {
"phantom-ui": PhantomUiAttributes;
}
}
}
import type { SolidPhantomUiAttributes } from "@aejkatappaja/phantom-ui";
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"phantom-ui": SolidPhantomUiAttributes;
}
}
}
import type { PhantomUiAttributes } from "@aejkatappaja/phantom-ui";
declare module "@builder.io/qwik" {
namespace QwikJSX {
interface IntrinsicElements {
"phantom-ui": PhantomUiAttributes & Record<string, unknown>;
}
}
}

Add this import to your root layout file:

import "@aejkatappaja/phantom-ui/ssr.css";
Framework Layout file
Next.js (App Router) app/layout.tsx
Next.js (Pages) pages/_app.tsx
Nuxt app.vue
SvelteKit src/routes/+layout.svelte
Remix app/root.tsx
Qwik src/root.tsx

TypeScript does not apply declare module augmentations from .d.ts files inside node_modules to other packages. This is a known TypeScript limitation that affects all Web Component libraries. The local .d.ts file works around this by being part of your project’s compilation context.