Extending Types
Estimated reading time: 2 minutesKita Html's type system can be extended to support custom elements, custom attributes, or both.
Custom elements
Declare new entries in JSX.IntrinsicElements to add custom HTML elements with typed
attributes.
Capitalized tags are components
JSX interprets capitalized tags as components. Use lowercase custom element names for
intrinsic elements. When the tag name cannot be written directly in JSX, use
<tag of="..."> instead.
Custom attributes on all elements
Extend the HtmlTag interface to add attributes to every native HTML element.
Allow any tag and attribute
If you need to bypass type checking entirely, add a triple-slash directive to your
src/kita.d.ts file. This is not recommended for production code.
Without the unrestricted type extension, unknown tags are rejected:
Add @kitajs/html/all-types to allow any tag and attribute: