Component Types
Jaspr offers three main approaches for rendering HTML:1. Pre-built HTML Components
Type-safe components for standard HTML elements likediv, span, button, etc. Each component class corresponds to a specific HTML tag.
2. DomComponent (Low-Level)
TheComponent.element() factory provides direct access to create any HTML element with full control over attributes, styles, and events.
3. Text Component
For rendering plain text nodes:Common Properties
All HTML components share these common properties:The HTML id attribute. Must be unique within the document.
CSS class names separated by whitespace.
Inline styles using the type-safe
Styles class. See Styles API.Additional HTML attributes as key-value pairs.
Event listeners where keys are event names (e.g., ‘click’, ‘submit’) and values are callbacks.
Child components to render inside this element.
Optional key for component identity and state preservation.
Available HTML Components
Jaspr includes components for all standard HTML elements:Text Elements
a,b,br,code,em,i,s,small,span,strong,u,wbr
Content Sections
article,aside,div,footer,header,main,nav,section,h1-h6,p
Forms
form,input,button,select,textarea,label,fieldset,legend
Media
img,video,audio,canvas,svg
Tables
table,thead,tbody,tr,td,th
Lists
ul,ol,li,dl,dt,dd
Example: Complete Component
Event Handling
Event callbacks receive the native browser event object:See Also
- Text Components - Text-level semantic elements
- DomComponent API - Low-level element creation
- Styles API - Type-safe CSS styling