Components
Components are the core building block of Lume. A component attaches reactive logic to an existing HTML element.
Defining a Component
Section titled “Defining a Component”Use defineComponent to create a component definition:
The factory function receives a Component Context and returns an optional public API object.
Registering Components
Section titled “Registering Components”Register components on a Lume app under a name that matches the data-lume attribute:
HTML Connection
Section titled “HTML Connection”Lume connects components to HTML via the data-lume attribute:
HTML Attributes
Section titled “HTML Attributes”| Attribute | Purpose |
|---|---|
data-lume | Marks the root element and specifies the component name |
data-lume-part | Marks a named child element inside the component |
data-lume-id | Assigns an ID for external access via app.get()/app.require() |
Multiple Instances
Section titled “Multiple Instances”Each data-lume element gets its own independent component instance:
Public API
Section titled “Public API”Return an object from your factory to expose a public API:
Access the API externally:
Lifecycle
Section titled “Lifecycle”- Mount: The factory runs when
.mount()is called on the app - Unmount: All effects, listeners, and cleanup functions run when
.unmount()is called - There is no “update” lifecycle — reactivity is handled by signals and effects