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

@carbon/icon-helpers

Package Overview
Dependencies
Maintainers
13
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@carbon/icon-helpers

Helpers used alongside icons for digital and software products using the Carbon Design System

  • 10.54.0
  • next
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
131K
decreased by-3.91%
Maintainers
13
Weekly downloads
 
Created

What is @carbon/icon-helpers?

@carbon/icon-helpers is a utility library for working with Carbon Design System icons. It provides a set of helper functions to manipulate and manage SVG icons, making it easier to integrate and customize icons within your projects.

What are @carbon/icon-helpers's main functionalities?

getAttributes

The `getAttributes` function generates a set of attributes for an SVG element based on the provided options. This is useful for ensuring that your SVG icons have the correct attributes for rendering.

const { getAttributes } = require('@carbon/icon-helpers');
const attributes = getAttributes({
  width: '32',
  height: '32',
  viewBox: '0 0 32 32',
  fill: 'currentColor'
});
console.log(attributes);

toString

The `toString` function converts an SVG element configuration into a string representation. This is useful for rendering SVG icons as strings, which can then be inserted into the DOM or used in other contexts.

const { toString } = require('@carbon/icon-helpers');
const svgString = toString({
  elem: 'svg',
  attrs: {
    width: '32',
    height: '32',
    viewBox: '0 0 32 32',
    fill: 'currentColor'
  },
  content: [{
    elem: 'path',
    attrs: {
      d: 'M16 2L2 30h28L16 2z'
    }
  }]
});
console.log(svgString);

formatAttributes

The `formatAttributes` function formats an object of attributes into a string that can be used directly in an HTML tag. This is useful for dynamically generating SVG elements with the correct attributes.

const { formatAttributes } = require('@carbon/icon-helpers');
const formattedAttributes = formatAttributes({
  width: '32',
  height: '32',
  viewBox: '0 0 32 32',
  fill: 'currentColor'
});
console.log(formattedAttributes);

Other packages similar to @carbon/icon-helpers

Keywords

FAQs

Package last updated on 24 Oct 2024

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