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

@devseed-ui/collecticons-react

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devseed-ui/collecticons-react

devseed UI Kit Collecticons for React

  • 3.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by66.67%
Maintainers
0
Weekly downloads
 
Created
Source

collecticons-banner

Collecticons for React

This modules allows you to use collecticons svg icons with a React base app.

yarn add @devseed-ui/collecticons-react

Props

NameTypeDefaultDescription
titlestringundefinedDescriptive title of the svg printed inside it. Required if meaningful is true.
meaningfulbooleanfalseDefines whether the icon has semantic meaning by setting the property of aria-hidden. When an icon is meaningful, a title property should be provided.

Decorative vs Meaningful icons

By default the collecticons are considered to be decorative elements (using aria-hidden="true"), but it is possible to give them semantic meaning by passing a descriptive title prop and defining them as meaningful.

<CollecticonBrandCollecticons title="The logo of the collecticons icon library" meaningful />

Creating custom icons (advanced)

Collecticons has an extensive selection of icons, but sometimes a project needs custom icons that are not (yet) available in the library.

These custom icons should be created the in same way collecticons are to ensure the correct interoperability between the different components where they're used. By design, Collections only have one color which is then controlled via props, so it is important that the constituents of the SVG have a fill set to currentColor.

A collecticon can be created using the function createCollecticon which should return a React Component and has the following signature:

import { createCollecticon } from '@devseed-ui/collecticons-react';

createCollecticon((props) => {}, iconSvgProps);

// props = {
//  title: string;
//  width: number;
//  height: number;
//  fill: string;
//  xmlns: string;
//  role: 'img';
//  viewBox: '0 0 16 16';
//  'aria-hidden': boolean;
//}

The SVG wrapper is added automatically, so only the icon path should be returned.

If there's the need to pass additional props to the SVG, they can be passed as the second argument to createCollecticon. As an example, if the icon was designed with a viewBox different from 0 0 16 16 this prop should be passed on creation.

Example The following SVG icon:

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
  <rect x="2" y="2" width="12" height="12" />
</svg>

Would be converted to a Collecticon as:

const CollecticonSquare = createCollecticon((props) => (
  <rect x="2" y="2" width="12" height="12" fill='currentColor' />
));

Keywords

FAQs

Package last updated on 16 Jul 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