Skip to content
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

Add tailwindcss-lit #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add tailwindcss-lit #120

wants to merge 1 commit into from

Conversation

ouweiya
Copy link

@ouweiya ouweiya commented Oct 31, 2023

Awesome Contribution Checklist:

  • I have read, and re-read the Contributing Guidelines
  • I have searched to ensure the suggested item doesn't exist on this list
  • This PR contains only one item

Please Provide a Link A Repository for Your Addition

https://github.com/ouweiya/rollup-plugin-tailwindcss-lit

Please Describe Your Addition

Using Tailwind CSS in Lit, importing CSS as modules, and supporting inline CSS compilation.

Compile CSS modules

import styles from 'index.css';

@customElement('my-element')
class One extends LitElement {
    static styles = [styles];

    render() {
        return html`<p class="text-blue-500">Hello</p>`;
    }
}

Compile inline CSS

static styles = [
    styles,
    css`
        :host {
            @apply text-blue-600;
            width: 100px;
        }
    `,
];

After compilation

static styles = [
    styles,
    css`
        :host {
            width: 100px;
        }
        :host {
            --tw-text-opacity: 1;
            color: rgb(37 99 235 / var(--tw-text-opacity));
        }
    `,
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant