Socket
Socket
Sign inDemoInstall

@commercetools-uikit/icons

Package Overview
Dependencies
97
Maintainers
3
Versions
787
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @commercetools-uikit/icons

All SVG icons are rendered as React components.


Version published
Weekly downloads
24K
increased by14.99%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

Icons

Description

All SVG icons are rendered as React components.

Usage

import { ExportIcon } from '@commercetools-uikit/icons';

<ExportIcon />;

Properties

PropsTypeRequiredValuesDefaultDescription
sizestring'small', 'medium', 'big', 'scale''big'Specifies the icon size (if scale is selected, the dimensions will scale according with the parents)
colorstring'solid', 'neutral60', 'info', 'primary', 'primary40', 'warning', 'error''solid'Specifies the icon color

Where to use

Main use cases are:

  • Buttons

    <SecondaryButton
      onClick={() => {}}
      iconLeft={<ExportIcon />}
      label={this.props.intl.formatMessage(messages.exportList)}
    />
    
  • Icon Buttons

    <IconButton
      onClick={() => {}}
      icon={<ExportIcon />}
      label={this.props.intl.formatMessage(messages.exportList)}
    />
    

Inline SVG for rendering custom icons

If you need to render an SVG icon that is not part of the default set of icons, it's possible to render it using a special component <InlineSvg>.

The component is exported as a separate entry point:

import InlineSvg from '@commercetools-uikit/icons/inline-svg';

Usage

import InlineSvg from '@commercetools-uikit/icons/inline-svg';

const svg = `<svg><path ... /></svg>`;

const App = () => <InlineSvg data={svg} color="primary" size="medium" />;

The component accepts the same props as the <*Icon> components color and size. Additionally it requires the data prop, which is the actual SVG content.

XSS protection

The data passed to the component is run through a DOM sanitizer to prevent unwanted XSS injections.

Where to use

This component can be used whenever the icon has to be rendered dynamically on runtime. For example in the Merchant Center this can be the case for the navigation menu icons, etc.

Leading Icon

The leading icon is a an eye-catching visual element that should be used when an additional visual prominence is needed for a content section in the UI. The different colours in combination with the icons can be utilised to create certain categorisation of the elements in the UI.

The component is exported as a separate entry point:

import LeadingIcon from '@commercetools-uikit/icons/leading-icon';

Usage

import LeadingIcon from '@commercetools-uikit/icons/leading-icon';
import { ExportIcon } from '@commercetools-uikit/icons';

const app = () => <LeadingIcon icon={<ExportIcon />} />;

Properties

PropsTypeRequiredValuesDefaultDescription
sizestring'10', '20', '30', '40''20'Specifies the icon size
colorstring'accent', 'brown', 'neutral', 'purple', 'turquoise', 'white''neutral'Specifies the icon's background color and fill color
isInvertedbooleantrue, falsefalseSpecifies whether the icon has a light background and dark fill (false), or dark background and light fill (true)
iconReactElementUI Kit <Icon/> componentIcon that is displayed within the component, you must supply a child icon with with this prop or the svg prop
svgstringA custom SVG to displayIcon that is displayed using the InlineSvg component, you must supply a child icon with with this prop or the icon prop

Where to use

This component can be used wherever it is necessary to display a themed icon.

Custom Icon

This component is meant to be used whenever consumers need to render an icon which is not part of the ui-kit icon set.

In order to keep visual consistency, we want to keep the available sizes of all icons equal. Bear in mind we would expect custom SVG icons to not contain size attributes so it can be controlled based on the components size attribute.

The component is exported as a separate entry point:

import CustomIcon from '@commercetools-uikit/icons/custom-icon';

Usage

import CustomIcon from '@commercetools-uikit/icons/custom-icon';
import { YourCustomIcon } from './your-custom-icon-directory';

const app = () => <Icon icon={<YourCustomIcon />} />;

Properties

PropsTypeRequiredValuesDefaultDescription
sizestring'10', '20', '30', '40''20'Specifies the icon size
iconunion
Possible values:
, ReactElement, string
-A ReactNode or string that display a custom SVGIcon displayed as a child of this component
hasBorderbooleantrue, falsefalseSpecifies whether the element displays a border

Keywords

FAQs

Last updated on 19 Jun 2024

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc