⚠️ This lesson is retired and might contain outdated information.

Lit in 60 Seconds

Rodrigo Pombo
InstructorRodrigo Pombo
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 2 years ago

Learn Lit fast. This is a quick overview of how to use Lit core features compressed into one minute. Remember to pause the video if you need time to understand something!

This lesson uses Lit v2.

To learn more about Lit and the rest of the features we haven't covered, visit the official website.

Rodrigo Pombo: [0:00] To create a component with Lit, you need to extend the LitElement class. Then, add the render() method and use that tag template literal to return html. You also need to use the customElement decorator, so you can use the element name from anywhere in your app.

[0:16] If you want to pass data to a custom element, use a class field with the property decorator, then you can render it inside the template literal.

[0:24] Templates can also include event listeners with this syntax. You can define internal state with the state decorator. Every time you change its state, Lit will re-render the component.

[0:37] You can dispatch CustomEvent to send data to the parent. CustomEvents can be handled in the same way as DOM events. If you want to repeat something based on a list, you map the array and nest the list of tag template literals.

[0:53] There is also a static styles property that only affect the elements within the component.

~ 14 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today