You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/pages/docs/components/anatomy.mdx
+51-5Lines changed: 51 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ Will result in:
100
100
101
101
Qwik host elements are marked with `q:host` attribute.
102
102
103
-
As you can see, `component$` will always create an extra element, by default is `div`, but that can be changed with `component$` options argument:
103
+
As you can see, `component$` will always create an extra element, by default is `div`, but that can be changed with `component$` options argument or the `tagName` attribute:
To control the tag name from inside of a `component$` use the [the Host tag](#host)
134
+
123
135
### `useHostElement()`
124
136
125
137
Since the host element is implicitly created by `component$`, it is not possible to access it directly. Instead, you can use `useHostElement()` to get the host element.
126
138
127
139
Qwik uses host elements in various ways. For example when using `useHostElement()` function which retrieves it. It is also used to attach props to the components for serialization.
128
140
129
-
130
-
131
-
132
141
## Host Element Attributes & Styling
133
142
134
143
Assume you have a component defined as so:
@@ -230,6 +239,43 @@ will result in:
230
239
</div>
231
240
```
232
241
242
+
You can also use the `<Host/>` component to set the tag name of the wrapper element generate by Qwik. This is very useful when building design systems.
0 commit comments