1.4.2 • Published 2 years ago

@icon-park/react v1.4.2

Weekly downloads
1,319
License
Apache-2.0
Repository
github
Last release
2 years ago

IconPark Icons

React Icons for IconPark

Introduction

Features

  • Provide more than 2000 icons
  • Provide 4 themes:
    • outline
    • filled
    • two-tone
    • multi-color

More

Please visit IconPark Website

  • Copy SVG
  • Copy React Icon component
  • Copy Vue Icon component
  • Download PNG
  • Download SVG

Getting Started

Install

npm install @icon-park/react --save

Include Component

Import an icon from @icon-park/reactat the top of a component and then use it in the render function:

import {Home} from '@icon-park/react';

// examples
<Home/>
<Home theme="filled"/>

Style Sheet

Import the icon style:

import '@icon-park/react/styles/index.css';

Or

import '@icon-park/react/styles/index.less';

Global Config

You can use IconProvider in @icon-park/react to set the default config globally:

import {IconProvider, DEFAULT_ICON_CONFIGS} from '@icon-park/react'
import {Home} from '@icon-park/react';

const IconConfig = {...DEFAULT_ICON_CONFIGS, prefix: 'icon'}

function App() {

    return (
        <IconProvider value={IconConfig}>
            <Home/>
            <Home theme="filled"/>
        </IconProvider>
    )
}

Import on Demand

You can use babel-plugin-import to import icons on demand.

Set config like this:

{
    "plugins": [
        [
            "import",
            {
                "libraryName": "@icon-park/react",
                "libraryDirectory": "es/icons",
                "camel2DashComponentName": false 
            }
        ]
    ]
}

Icon Component

We recommend loading icons on demand, because this can greatly reduce the volume of compiled code。 However, in some scenarios similar to remote loading menus, direct reference to all icons can reduce the development cost.

Usage:

import Icon, {IconType} from '@icon-park/react/es/all';
import React, {Fragment} from 'react';

export function Demo(props: {type: IconType}): JSX.Element {

    const {type} = props;

    return (
        <Fragment>
            <Icon type={type} theme="filled" />
            <Icon type="AddText" theme="filled" />
            <Icon type="add-text" />
        </Fragment>
    )
}

You can do this when you are not sure whether the type property is legal:

import Icon, {ALL_ICON_KEYS, IconType} from '@icon-park/react/es/all';
import React, {Fragment} from 'react';

export function Demo(props: {type: IconType}): JSX.Element {

    const {type} = props;

    if(ALL_ICON_KEYS.indexOf(type) < 0) {
        return (
            <span>Not Exists</span>
        );
    }

    return (
        <Fragment>
            <Icon type={type} theme="filled" />
            <Icon type="People" theme="filled" />
            <Icon type="Switch" />
        </Fragment>
    )
}

Embed IconPark in your project

If you need to use additional information such as icon name, author, category, label and creation time, you can use the icons.json file located in the root directory of each NPM.

Props

propdescriptiontypedefaultnote
themeTheme of the icons.'outline' | 'filled' | 'two-tone' | 'multi-color''outline'
sizeThe width/height of the iconnumber | string'1em'
spinRotate icon with animationbooleanfalse
fillColors of themestring | string[]'currentColor'
strokeLinecapthe stroke-linecap prop of svg element'butt' | 'round' | 'square''round'
strokeLinejointhe stroke-linejoin prop of svg element'miter' | 'round' | 'bevel''round'
strokeWidththe stroke-width prop of svg elementnumber4

Other props

You can use all props which are defined in HTMLAttributes<HTMLSpanElement>>, such as:

  • className
  • style
  • onClick
  • ...
1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.5

3 years ago

1.3.3

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.5-alpha.1

3 years ago

1.1.5

3 years ago

1.1.5-alpha.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.15-alpha.0

3 years ago

1.0.14

3 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago