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

Recommended tailwind styling? #40

Closed
silveltman opened this issue Jul 3, 2022 · 3 comments · Fixed by #106
Closed

Recommended tailwind styling? #40

silveltman opened this issue Jul 3, 2022 · 3 comments · Fixed by #106
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@silveltman
Copy link

First of all, awesome plugin!

I'm like using tailwind but am not sure which way is best to style the icons. Something like below?

---
import { Icon } from 'astro-icon';
---

<style lang="css">
    [astro-icon] {
        @apply text-blue
        /* OR */
        @apply text-blue
    }
    [astro-icon="annotation"] {
        @apply text-red
        /* OR */
        @apply text-red
    }
</style>

<Icon name="adjustment" /> <!-- will be blue -->
<Icon name="annotation" /> <!-- will be red -->

If so, might be useful to take up in the README.

I think it will be a great addition to add a 'class' prop. Would make things a lot easier when using tailwind and protentially cleaner in some cases when using regular styles.

@JulianCataldo
Copy link

JulianCataldo commented Jul 15, 2022

Hello,

I use it like this, it works for me:

<Icon name="system-uicons:trash" size={'1em'} class="salut" />

👇🏻

<svg viewBox="0 0 21 21" width="1em" height="1em" astro-icon="system-uicons:trash" class="salut astro-M4RLHIZ3">
...
</svg>

@stramel
Copy link
Collaborator

stramel commented Oct 20, 2022

It sounds like the documentation of styling the Astro-Icons could be improved to include documentation about the exposed class property.

@stramel stramel added documentation Improvements or additions to documentation good first issue Good for newcomers labels Oct 20, 2022
@zoxon
Copy link

zoxon commented Jan 5, 2023

Ignore astro-icon styles and use fill

<Icon name="menu" class="fill-blue-500 w-5 h-5" />

or use this styles

[astro-icon] {
  fill: currentColor;
}

@stramel stramel added this to the v0.9 milestone May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants