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 universal support for color attribute (similar to CSS icons) #176

Closed
Rednas83 opened this issue Jun 22, 2024 · 5 comments
Closed

Add universal support for color attribute (similar to CSS icons) #176

Rednas83 opened this issue Jun 22, 2024 · 5 comments

Comments

@Rednas83
Copy link

<Icon name="uil:github" color="red" />
returns
image
App.config.ts

// https://github.com/nuxt-modules/icon#configuration-%EF%B8%8F
export default defineAppConfig({
  icon: {
    size: "300%", // default <Icon> size applied
    class: "icon", // default <Icon> class applied
    mode: "css", // svg || css
    aliases: {
      nuxt: "logos:nuxt-icon",
    },
  },
})
@antfu
Copy link
Member

antfu commented Jun 22, 2024

Use style="color:red" instead.

@Rednas83
Copy link
Author

Rednas83 commented Jul 1, 2024

This works just like class="text-red-600" for tailwind users. But the docs still mentions color in the example
image

Will color as a shorthand be supported again or should the docs be updated?

@danjrwalsh
Copy link
Contributor

This works just like class="text-red-600" for tailwind users. But the docs still mentions color in the example image

Will color as a shorthand be supported again or should the docs be updated?

The color attribute in that reference is regarding the built-in attribute available on the SVG element, that's why it's below the message "you can give all the attributes of the native element" and has a link to the mozilla doc for SVG.

With that said, I do agree that it's a bit confusing in that context.

When using CSS icons (the default now), you must use style or class, otherwise for SVG icons you can continue to use color like you did previously.

@Rednas83
Copy link
Author

Rednas83 commented Jul 6, 2024

Ok, I migrated to style for now

:color="page.name == selected ? settings.color : page.name == 'Alarms' && coptions.alarm ? 'red' : 'black'" // ISSUE: Not supported
:class="page.name == selected ? `text-[${settings.color}]` : page.name == 'Alarms' && coptions.alarm ? 'text-red-600' : 'text-black'" // ISSUE: Only typed colors are supported
:style="{ color: page.name == selected ? settings.color : page.name == 'Alarms' && coptions.alarm ? 'red' : 'black' }" // ISSUE: Little less convenient??

Is it an idea to also support the color attribute for svg icons? It would make the library much more universal I think🤔

And perhaps also add universal support stroke-width while at it?

@Rednas83 Rednas83 changed the title Color attribute is not longer working in 1.0.0 Add universal support for color attribute (similar to CSS icons) Jul 6, 2024
@antfu antfu closed this as completed in f51af19 Jul 15, 2024
@antfu
Copy link
Member

antfu commented Jul 15, 2024

color attribute is a SVG specific feature, just updated the docs to correct the example.

For stroke-width, please keep an eye on #199

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

No branches or pull requests

3 participants