SolidJS
Use staticview components in SolidJS JSX.
TypeScript Configuration
Add the component types to your TypeScript configuration:
{ "compilerOptions": { "types": [ // Required: types the component tags in Solid JSX // For one component: "@staticview/ui/types/solid/[component-name]" "@staticview/ui/types/solid",
// Optional: types what `querySelector` and `createElement` return for each tag // For one component: "@staticview/ui/types/dom/[component-name]" "@staticview/ui/types/dom",
// Optional: declares each component type globally, with no import // For one component: "@staticview/ui/types/global/[component-name]" "@staticview/ui/types/global", ], },}Importing Web Components
Since components register globally, import each one once, in your app's entry point:
import "@staticview/ui/[component-name]";Setting Properties
Set a property with prop:[propertyName]:
<component-name prop:opened={isOpen()}></component-name>Setting Attributes
Set an attribute as in plain HTML:
<component-name label="Title"></component-name>Boolean Attributes
A boolean attribute is on whenever it is present, and close-button="false" turns the close button on. Since Solid assigns an attribute on a custom element as the matching property, like close-button as closeButton, pass a boolean:
<component-name close-button={hasCloseButton()}></component-name>When the component has a matching property, prefer prop:, which says the same thing explicitly:
<component-name prop:closeButton={hasCloseButton()}></component-name>To set a real attribute, use the attr: prefix, with "" to turn it on and undefined to turn it off:
<component-name attr:close-button={hasCloseButton() ? "" : undefined}></component-name>Handling Events
Listen to component events with on:[eventName]:
<component-name on:openedchange={handleOpenedChange}></component-name>Using Slots
Put the content between the tags, with a slot attribute for a named slot:
<component-name> <span slot="title">Title</span> <span>Content</span></component-name>