Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

astro-icon

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-icon

A straight-forward `Icon` component for [Astro](https://astro.build).

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32K
decreased by-14.85%
Maintainers
1
Weekly downloads
 
Created
Source

Astro Icon

A straight-forward Icon component for Astro.

astro-icon will automatically optimize icons with svgo and inline them directly into your HTML—no extra build step, no spritesheet complexity, no cross-browser concerns! See "A Pretty Good SVG Icon System" from CSS Tricks.

Usage

  1. Install astro-icon.
npm i astro-icon
# or
yarn add astro-icon
  1. Create a directory inside of src/ named icons/.
  2. Add each desired icon as an individual .svg file to src/icons/
  3. Reference a specific icon file using the name prop.
---
import Icon from 'astro-icon';
---

<!-- Loads the SVG in `/src/icons/filename.svg` -->
<Icon name="filename" />

Styling

Styling your astro-icon is straightforward. Any styles can be targeted to the [astro-icon] attribute selector. If you want to target a specific icon, you may target it by name using [astro-icon="filename"].

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

<style lang="css">
    [astro-icon] {
        color: blue;
    }
    [astro-icon="annotation"] {
        color: red;
    }
</style>

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

Props

<Icon> requires the name prop to reference a specific icon.

<Icon> optionally accepts the optimize prop as a boolean. Defaults to true. In the future it will control svgo options.

<Icon> also accepts any global HTML attributes and aria attributes. They will be forwarded to the rendered <svg> element.

See the Props.ts file for more details.

Keywords

FAQs

Package last updated on 04 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc