) {
h1 {
text(title)
}
}
fun Html.MyBlog() {
Title("My Blog")
val title = signal("My Blog")
Title(title)
}
```
--------------------------------
### HTML Paragraph (p)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/-html/index
Represents a paragraph of text. Supports standard HTML attributes and event handlers.
```APIDOC
## HTML Paragraph (P) Element
### Description
Creates a paragraph (``) element for text content. Supports common HTML attributes and event handlers.
### Method
`Html.p(...)`
### Endpoint
N/A (This is a client-side HTML element creation function)
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```kotlin
p {
text("This is a paragraph of text.")
}
```
### Response
#### Success Response (200)
Returns an `HTMLParagraphElement` representing the paragraph.
#### Response Example
N/A (This function generates an HTML element, not a typical API response)
```
--------------------------------
### Handle Lifecycle Events in Komponent
Source: https://komponent.sparky983.me/docs/component
Illustrates how to listen for component lifecycle events, specifically `onMount` and `onUnmount`, within Komponent. This is useful for managing resources associated with a component's presence in the DOM.
```kotlin
/*
All elements have two life cycle stages that can occur an indefinite amount of times:
* Mounting
* Unmounting
You can listen for them with `onMount` and `onUnmount` respectively. This is useful for managing resources.
*/
```
--------------------------------
### Compiler Integration for Signals in Kotlin
Source: https://komponent.sparky983.me/docs/reactivity
Explains how the Komponent Compiler allows functions accepting `Signal` to be called with regular values. The compiler handles the necessary signal creation and subscription.
```kotlin
fun log(signal: Signal) {
signal.subscribe { println(it) }
}
log("Hello, world!") // "Hello, world!"
```
--------------------------------
### HTML Anchor Element (a)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/-html
Creates an anchor element () with various attributes and event handlers.
```APIDOC
## Html.a
### Description
Creates an anchor element () which is used to link documents together.
### Method
POST (or equivalent function call in the framework)
### Endpoint
N/A (This is a function call within a framework)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **className** (Signal?): Optional CSS class name for the element.
- **draggable** (Signal?): Optional attribute to make the element draggable.
- **id** (Signal?): Optional unique identifier for the element.
- **style** (Signal?): Optional inline style for the element.
- **tabIndex** (Signal?): Optional tab order index for the element.
- **title** (Signal?): Optional tooltip text for the element.
- **href** (Signal): Required URL to link to.
- **download** (Signal?): Optional attribute to suggest a filename for downloaded content.
- **onBlur** (EventHandler?): Event handler for when the element loses focus.
- **onClick** (EventHandler?): Event handler for when the element is clicked.
- **onFocus** (EventHandler?): Event handler for when the element gains focus.
- **onFocusIn** (EventHandler?): Event handler for when focus enters the element.
- **onFocusOut** (EventHandler?): Event handler for when focus leaves the element.
- **onKeyDown** (EventHandler?): Event handler for when a key is pressed down.
- **onKeyUp** (EventHandler?): Event handler for when a key is released.
- **onLoad** (EventHandler?): Event handler for when the element finishes loading.
- **onMouseDown** (EventHandler?): Event handler for when a mouse button is pressed down.
- **onMouseEnter** (EventHandler?): Event handler for when the mouse pointer enters the element.
- **onMouseLeave** (EventHandler?): Event handler for when the mouse pointer leaves the element.
- **onMouseMove** (EventHandler?): Event handler for when the mouse pointer moves over the element.
- **onMouseOut** (EventHandler?): Event handler for when the mouse pointer moves out of the element.
- **onMouseover** (EventHandler?): Event handler for when the mouse pointer is over the element.
- **onMouseUp** (EventHandler?): Event handler for when a mouse button is released.
- **onUnload** (EventHandler?): Event handler for when the element is unloaded.
- **onWheel** (EventHandler?): Event handler for when the mouse wheel is scrolled.
- **data** (Attributes?): Optional custom data attributes.
- **children** (Children): Content of the anchor element.
### Request Example
```kotlin
Html.a(
href = Signal("https://example.com"),
className = Signal("my-link")
) { Text("Click me") }
```
### Response
#### Success Response (200)
Returns an `HTMLAnchorElement` representing the created anchor tag.
#### Response Example
```html
Click me
```
```
--------------------------------
### HTML Article Element (article)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/-html/index
Creates an HTML article element (). This element represents a self-contained piece of content that is independently distributable or reusable.
```APIDOC
## Html.article
### Description
Creates an HTML article element () with specified attributes and event handlers.
### Method
Not applicable (this is a function call, not an HTTP request).
### Endpoint
Not applicable.
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```kotlin
// Example of creating an article element
val articleElement = Html.article { Text("This is a blog post.") }
```
### Response
#### Success Response
- **HTMLElement**: The created article element.
#### Response Example
```html
This is a blog post.
```
```
--------------------------------
### Provide
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/index
Provides a context value to all children elements. This is useful for dependency injection or state management.
```APIDOC
## Provide
### Description
Provides the given context value for the context type to all children.
### Method
`Html.Provide(value: T, noinline children: Children)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```kotlin
// Example usage (assuming 'Html' is available in scope)
Html.Provide(value = "some context data") {
// Children elements that can access the provided value
span { text("Content within context") }
}
```
### Response
#### Success Response (200)
This function does not return a value directly but establishes a context for its children.
#### Response Example
N/A
```
--------------------------------
### Komponent Component with Children Prop
Source: https://komponent.sparky983.me/docs/component
Shows how to handle nested components or content within a Komponent component using the `Children` type as the last parameter. `Children` is a shorthand for `Html.() -> Unit`.
```kotlin
enum class ButtonKind {
PRIMARY,
SECONDARY
}
fun Html.Button(kind: ButtonKind, children: Children) {
when (kind) {
PRIMARY -> button(className = "primary") {
children()
}
SECONDARY -> button(className = "secondary") {
children()
}
}
}
```
--------------------------------
### Dynamic Component Rendering with Dynamic Component (Kotlin)
Source: https://komponent.sparky983.me/docs/reactivity
Demonstrates the `Dynamic` component, which rerenders its children whenever a provided `Signal` is updated. This is useful for scenarios where an entire component needs to be refreshed based on state changes.
```kotlin
fun Html.Tabs(tab: MutableSignal) {
button(onClick = { tab.value = Tab.FIRST }) { text("first") }
button(onClick = { tab.value = Tab.SECOND }) { text("Second") }
Dynamic(tab) {
when (it) {
FIRST -> {}
SECOND -> {}
}
}
}
```
--------------------------------
### Create HTML BRElement with Kotlin
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/br
This function generates an HTMLBRElement, which represents a line break in HTML. It accepts numerous optional parameters for attributes like 'className', 'id', 'style', and event handlers for various user interactions and lifecycle events. The 'source' parameter is an internal detail of the Komponent library.
```kotlin
fun Html.br( className: Signal? = null, draggable: Signal? = null, id: Signal? = null, style: Signal? = null, tabIndex: Signal? = null, title: Signal? = null, onBlur: EventHandler? = null, onClick: EventHandler? = null, onFocus: EventHandler? = null, onFocusIn: EventHandler? = null, onFocusOut: EventHandler? = null, onKeyDown: EventHandler? = null, onKeyUp: EventHandler? = null, onLoad: EventHandler? = null, onMouseDown: EventHandler? = null, onMouseEnter: EventHandler? = null, onMouseLeave: EventHandler? = null, onMouseMove: EventHandler? = null, onMouseOut: EventHandler? = null, onMouseover: EventHandler? = null, onMouseUp: EventHandler? = null, onUnload: EventHandler? = null, onWheel: EventHandler? = null, data: Attributes? = null): HTMLBRElement(source)
```
--------------------------------
### Create HTML Article Element (article)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/index
Facilitates the creation of an HTML article element (``). This function includes support for a wide range of optional attributes and event handlers, providing flexibility in defining article content and behavior. It returns an `HTMLElement`.
```kotlin
fun Html.article(className: Signal? = null, draggable: Signal? = null, id: Signal? = null, style: Signal? = null, tabIndex: Signal? = null, title: Signal? = null, onBlur: EventHandler? = null, onClick: EventHandler? = null, onFocus: EventHandler? = null, onFocusIn: EventHandler? = null, onFocusOut: EventHandler? = null, onKeyDown: EventHandler? = null, onKeyUp: EventHandler? = null, onLoad: EventHandler? = null, onMouseDown: EventHandler? = null, onMouseEnter: EventHandler? = null, onMouseLeave: EventHandler? = null, onMouseMove: EventHandler? = null, onMouseOut: EventHandler? = null, onMouseover: EventHandler? = null, onMouseUp: EventHandler? = null, onUnload: EventHandler? = null, onWheel: EventHandler? = null, data: Attributes? = null, children: Children): HTMLElement
```
--------------------------------
### HTML Address Element (address)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/-html
Creates an address element () with various attributes and event handlers.
```APIDOC
## Html.address
### Description
Creates an address element () which typically contains contact information for the author/owner of a document or article.
### Method
POST (or equivalent function call in the framework)
### Endpoint
N/A (This is a function call within a framework)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **className** (Signal?): Optional CSS class name for the element.
- **draggable** (Signal?): Optional attribute to make the element draggable.
- **id** (Signal?): Optional unique identifier for the element.
- **style** (Signal?): Optional inline style for the element.
- **tabIndex** (Signal?): Optional tab order index for the element.
- **title** (Signal?): Optional tooltip text for the element.
- **onBlur** (EventHandler?): Event handler for when the element loses focus.
- **onClick** (EventHandler?): Event handler for when the element is clicked.
- **onFocus** (EventHandler?): Event handler for when the element gains focus.
- **onFocusIn** (EventHandler?): Event handler for when focus enters the element.
- **onFocusOut** (EventHandler?): Event handler for when focus leaves the element.
- **onKeyDown** (EventHandler?): Event handler for when a key is pressed down.
- **onKeyUp** (EventHandler?): Event handler for when a key is released.
- **onLoad** (EventHandler?): Event handler for when the element finishes loading.
- **onMouseDown** (EventHandler?): Event handler for when a mouse button is pressed down.
- **onMouseEnter** (EventHandler?): Event handler for when the mouse pointer enters the element.
- **onMouseLeave** (EventHandler?): Event handler for when the mouse pointer leaves the element.
- **onMouseMove** (EventHandler?): Event handler for when the mouse pointer moves over the element.
- **onMouseOut** (EventHandler?): Event handler for when the mouse pointer moves out of the element.
- **onMouseover** (EventHandler?): Event handler for when the mouse pointer is over the element.
- **onMouseUp** (EventHandler?): Event handler for when a mouse button is released.
- **onUnload** (EventHandler?): Event handler for when the element is unloaded.
- **onWheel** (EventHandler?): Event handler for when the mouse wheel is scrolled.
- **data** (Attributes?): Optional custom data attributes.
- **children** (Children): Content of the address element.
### Request Example
```kotlin
Html.address { Text("123 Main St, Anytown, USA") }
```
### Response
#### Success Response (200)
Returns an `HTMLElement` representing the created address tag.
#### Response Example
```html
123 Main St, Anytown, USA
```
```
--------------------------------
### HTML Bold Element (b)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/-html
Creates a bold element () with various attributes and event handlers.
```APIDOC
## Html.b
### Description
Creates a bold element () which is used to draw attention to a piece of text without conveying any extra importance.
### Method
POST (or equivalent function call in the framework)
### Endpoint
N/A (This is a function call within a framework)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **className** (Signal?): Optional CSS class name for the element.
- **draggable** (Signal?): Optional attribute to make the element draggable.
- **id** (Signal?): Optional unique identifier for the element.
- **style** (Signal?): Optional inline style for the element.
- **tabIndex** (Signal?): Optional tab order index for the element.
- **title** (Signal?): Optional tooltip text for the element.
- **onBlur** (EventHandler?): Event handler for when the element loses focus.
- **onClick** (EventHandler?): Event handler for when the element is clicked.
- **onFocus** (EventHandler?): Event handler for when the element gains focus.
- **onFocusIn** (EventHandler?): Event handler for when focus enters the element.
- **onFocusOut** (EventHandler?): Event handler for when focus leaves the element.
- **onKeyDown** (EventHandler?): Event handler for when a key is pressed down.
- **onKeyUp** (EventHandler?): Event handler for when a key is released.
- **onLoad** (EventHandler?): Event handler for when the element finishes loading.
- **onMouseDown** (EventHandler?): Event handler for when a mouse button is pressed down.
- **onMouseEnter** (EventHandler?): Event handler for when the mouse pointer enters the element.
- **onMouseLeave** (EventHandler?): Event handler for when the mouse pointer leaves the element.
- **onMouseMove** (EventHandler?): Event handler for when the mouse pointer moves over the element.
- **onMouseOut** (EventHandler?): Event handler for when the mouse pointer moves out of the element.
- **onMouseover** (EventHandler?): Event handler for when the mouse pointer is over the element.
- **onMouseUp** (EventHandler?): Event handler for when a mouse button is released.
- **onUnload** (EventHandler?): Event handler for when the element is unloaded.
- **onWheel** (EventHandler?): Event handler for when the mouse wheel is scrolled.
- **data** (Attributes?): Optional custom data attributes.
- **children** (Children): Content of the bold element.
### Request Example
```kotlin
Html.b { Text("This text is bold.") }
```
### Response
#### Success Response (200)
Returns an `HTMLElement` representing the created bold tag.
#### Response Example
```html
This text is bold.
```
```
--------------------------------
### Create Textarea Input (Kotlin)
Source: https://komponent.sparky983.me/api/komponent/me.sparky983.komponent/index
Creates an HTML textarea element with support for various attributes and event handlers. It allows for dynamic configuration through Signals.
```kotlin
fun Html.textarea(className: Signal? = null, draggable: Signal? = null, id: Signal? = null, style: Signal? = null, tabIndex: Signal? = null, title: Signal? = null, autoCapitalize: Signal? = null, autoCorrect: Signal? = null, autoFocus: Signal? = null, cols: Signal? = null, dirName: Signal? = null, disabled: Signal? = null, form: Signal? = null, maxLength: Signal? = null, minLength: Signal? = null, multiple: Signal