aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Elian ☕️ <hello@elian.codes> 2023-08-04 16:43:03 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-04 16:43:03 +0200
commit37e18a9160e04e17a3ae3f4631cce12a8cc9662d (patch)
tree44fc080d6bb829e2ac1f17ced68d3f56ea932a26
parent60616bb7172d70f495d5631036643ec45de29e67 (diff)
downloadastro-37e18a9160e04e17a3ae3f4631cce12a8cc9662d.tar.gz
astro-37e18a9160e04e17a3ae3f4631cce12a8cc9662d.tar.zst
astro-37e18a9160e04e17a3ae3f4631cce12a8cc9662d.zip
docs: Update Lit README.md (#7960)
-rw-r--r--packages/integrations/lit/README.md15
1 files changed, 4 insertions, 11 deletions
diff --git a/packages/integrations/lit/README.md b/packages/integrations/lit/README.md
index 1a71ce3c6..9fde521a0 100644
--- a/packages/integrations/lit/README.md
+++ b/packages/integrations/lit/README.md
@@ -61,35 +61,28 @@ To use your first Lit component in Astro, head to our [UI framework documentatio
- 💧 client-side hydration options, and
- 🤝 opportunities to mix and nest frameworks together
-However, there's a key difference with Lit _custom elements_ over conventional _components_: you can use the element tag name directly.
-
-Astro needs to know which tag is associated with which component script. We expose this through exporting a `tagName` variable from the component script. It looks like this:
+Writing and importing a Lit component in Astro looks like this:
```js
// src/components/my-element.js
import { LitElement, html } from 'lit';
-const tagName = 'my-element';
-
export class MyElement extends LitElement {
render() {
return html` <p>Hello world! From my-element</p> `;
}
}
-customElements.define(tagName, MyElement);
+customElements.define('my-element', MyElement);
```
-> Note that exporting the `tagName` is **required** if you want to use the tag name in your templates. Otherwise you can export and use the constructor, like with non custom element frameworks.
-
-In your Astro template import this component as a side-effect and use the element.
+Now, the component is ready to be imported via the Astro frontmatter:
```astro
----
// src/pages/index.astro
+---
import { MyElement } from '../components/my-element.js';
---
-
<MyElement />
```