-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to style host and slot elements with Lit #504
Comments
It's possible to add classes to host element with one of the lifecycle methods, such as firstUpdate(). It executes tasks that need to be performed once the component's DOM has been created. Below will add 'tw-class' to host element.
Another way is to style :host element when component property is set. |
I wouldn't have a host modify it's own
What does that mean concretely? Like this: import {LitElement, html, css} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import { defineConfig } from '@twind/core'
import install from '@twind/with-web-components';
const config = defineConfig({});
const WithTwind = install(config);
@customElement('simple-greeting')
export class SimpleGreeting extends WithTwind(LitElement) {
static styles = css`
:host {
display: block;
border: solid 1px red;
background: @apply bg-blue-500;
}
`;
@property()
name = 'World';
render() {
return html`<h2>Hello, ${this.name}</h2>`;
}
} because the
This is probably because |
The documentation for lit https://twind.style/with-lit only provides an example of how to use tailwind classes in the render function, but there seems to be no way to style the
:host
element without using standard css. Passing classes to a slot element seems to also do nothing.Are there any example of these?
Thanks!
The text was updated successfully, but these errors were encountered: