@@ -20,6 +20,7 @@ with an automatic JSX runtime.
2020* [ API] ( #api )
2121 * [ ` toJsxRuntime(tree, options) ` ] ( #tojsxruntimetree-options )
2222 * [ ` Options ` ] ( #options )
23+ * [ ` Components ` ] ( #components-1 )
2324 * [ ` Fragment ` ] ( #fragment-1 )
2425 * [ ` Jsx ` ] ( #jsx-1 )
2526 * [ ` JsxDev ` ] ( #jsxdev-1 )
@@ -143,6 +144,13 @@ Static JSX ([`Jsx`][jsx], required in production).
143144
144145Development JSX ([ ` JsxDev ` ] [ jsxdev ] , required in development).
145146
147+ ###### ` components `
148+
149+ Components to use ([ ` Partial<Components> ` ] [ components ] , optional).
150+
151+ Each key is the name of an HTML (or SVG) element to override.
152+ The value is the component to render instead.
153+
146154###### ` development `
147155
148156Whether to use ` jsxDEV ` when on or ` jsx ` and ` jsxs ` when off (` boolean ` ,
170178> Passing SVG might break but fragments of modern SVG should be fine.
171179> Use ` xast ` if you need to support SVG as XML.
172180
181+ ### ` Components `
182+
183+ Possible components to use (TypeScript type).
184+
185+ Each key is a tag name typed in ` JSX.IntrinsicElements ` .
186+ Each value is a component accepting the corresponding props or a different tag
187+ name.
188+
189+ You can access props at ` JSX.IntrinsicElements ` .
190+ For example, to find props for ` a ` , use ` JSX.IntrinsicElements['a'] ` .
191+
192+ ###### Type
193+
194+ ``` ts
195+ type Components = {
196+ [TagName in keyof JSX .IntrinsicElements ]:
197+ | Component <JSX .IntrinsicElements [TagName ]>
198+ | keyof JSX .IntrinsicElements
199+ }
200+
201+ type Component <ComponentProps > =
202+ // Function component:
203+ | ((props : ComponentProps ) => JSX .Element | string | null | undefined )
204+ // Class component:
205+ | (new (props : ComponentProps ) => JSX .ElementClass )
206+ ` ` `
207+
173208### ` Fragment `
174209
175210Represent the children, typically a symbol (TypeScript type).
@@ -348,9 +383,9 @@ followed by browsers such as Chrome, Firefox, and Safari.
348383## Types
349384
350385This package is fully typed with [ TypeScript] [ ] .
351- It exports the additional types [ ` Fragment ` ] [ fragment ] , [ ` Jsx ` ] [ jsx ] ,
352- [ ` JsxDev ` ] [ jsxdev ] , [ ` Options ` ] [ options ] , [ ` Props ` ] [ props ] , [ ` Source ` ] [ source ] ,
353- and [ ` Space ` ] [ Space ] .
386+ It exports the additional types [ ` Components ` ] [ components ] ,
387+ [ ` Fragment ` ] [ fragment ] , [ ` Jsx ` ] [ jsx ] , [ ` JsxDev ` ] [ jsxdev ] , [ ` Options ` ] [ options ] ,
388+ [ ` Props ` ] [ props ] , [ ` Source ` ] [ source ] , and [ ` Space ` ] [ Space ] .
354389
355390The function ` toJsxRuntime ` returns a ` JSX.Element ` , which means that the JSX
356391namespace has to by typed.
@@ -463,3 +498,5 @@ abide by its terms.
463498[ source ] : #source
464499
465500[ space ] : #space-1
501+
502+ [ components ] : #components-1
0 commit comments