@fonticonpicker/react-fonticonpicker

中文文档
1.2.0发布于 2018/10/21MITCommonJS零依赖近 30 天下载 3149

A react component to show a picker element to select font icons or SVG.

原始使用文档
文档目录8 节
  1. Installation
  2. NPM or YARN
  3. CDN
  4. Download Source
  5. Usage
  6. Props
  7. Development Environment
  8. Credits

React FontIconPicker Component

codecov Build Status jest npm version peerDependencies Status GitHub license


FontIconPicker

A react version of fontIconPicker. This is rewritten and is not a wrapper around jQuery version.

With FontIconPicker component you can present an UI where people can pick one or more fonts. In bare-bone it looks like this.

Installation

NPM or YARN

NPM is the preferred way of installation. You can find it from here.

From your project do

npm i @fonticonpicker/react-fonticonpicker

Also install the peer dependencies yourself.

npm i react react-dom classnames prop-types react-transition-group

And require the file.

ES6

import FontIconPicker from '@fonticonpicker/react-fonticonpicker';

ES5

const FontIconPicker = require('@fonticonpicker/react-fonticonpicker');

And use it as React Component. Check the documentation site for more example.

CDN

For some reason, if you'd prefer the CDN, then it is available at unpkg.com.

Place them in your HTML document, along with UMD builds of peer dependencies.

Download Source

We distribute production version of source file through github releases. Head over there and download fonticonpicker.react.zip file.

Usage

Here is an example for use with the create-react-app.

From your project directory do:

yarn add classnames prop-types react-transition-group @fonticonpicker/react-fonticonpicker

Now edit your App.js file to include the following.

import React, { Component } from 'react';
import FontIconPicker from '@fonticonpicker/react-fonticonpicker';
import logo from './logo.svg';
import './App.css';
import '@fonticonpicker/react-fonticonpicker/dist/fonticonpicker.base-theme.react.css';
import '@fonticonpicker/react-fonticonpicker/dist/fonticonpicker.material-theme.react.css';

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 'fipicon-angle-left',
    };
  }
  handleChange = (value) => {
    this.setState({ value });
  }
  render() {
    const props = {
      icons: ['fipicon-angle-left', 'fipicon-angle-right', 'fipicon-angle-up', 'fipicon-angle-down'],
      theme: 'bluegrey',
      renderUsing: 'class',
      value: this.state.value,
      onChange: this.handleChange,
      isMulti: false,
    };
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to React</h1>
        </header>
        <FontIconPicker {...props} />
      </div>
    );
  }
}

export default App;

create-react-app

This will render a basic FontIconPicker component. For advanced usage, follow the documentation.

Props

PropTypeRequiredDefault
iconsobject of array or arrayyesN/A
onChangefuncyesN/A
searchobject of array or arraynonull
iconsPerPagenumberno20
themestringno'default'
showCategoryboolnotrue
showSearchboolnotrue
valuearray or stringnonull
isMultiboolnofalse
renderUsingstringno'class'
convertHexboolnotrue
renderFuncfuncnonull
appendTostringnofalse
allCatPlaceholderstringno'Show from all'
searchPlaceholderstringno'Search Icons'
noIconPlaceholderstringno'No icons found'
noSelectedPlaceholderstringno'Select icon'

Development Environment

Development & Build is done with the help of webpack.

First fork and git clone the repo on your machine.

git clone [email protected]:<username>/react-fonticonpicker.git

Now install all the dependencies. Make sure you have nodejs version 9 or higher.

npm install

Now run the server with

npm start

This will open a webpack dev server with hot reload. You can access the server from http://localhost:7770.

Now make changes in the component and see it live. Also add unit tests and integration tests where applicable.

If your changes invalidates snapshots, then make sure to update them too (with good reasons).

When doing a PR, try not to build the docs or the dist. It will create unnecessary merge conflict.

Other npm commands at disposal:

  • npm run test: Runs eslint followed by stylelint and jest tests.
  • npm run start: Runs a dev server with hot reload.
  • npm run docs: Builds the docs for production.
  • npm run build: Builds the UMD & CSS files for distribution.

Credits

React FontIconPicker has been developed by Swashata mainly for in use with eForm. The original idea came from jQuery FontIconPicker by Alessandro Benoit.

None of these would have been possible without the cool Wes Bos 🔥 and his react for beginners course. It is awesome 😉.

版本与发布记录

@fonticonpicker/react-fonticonpicker 共发布 6 个版本,首次发布于 2018/04/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.0latest2018/10/218 年前
1.1.02018/04/118 年前
1.0.02018/04/108 年前
0.0.92018/04/108 年前
0.0.32018/04/078 年前
0.0.12018/04/068 年前

关于 @fonticonpicker/react-fonticonpicker 的常见问题

@fonticonpicker/react-fonticonpicker 是什么?

A react component to show a picker element to select font icons or SVG.

如何安装 @fonticonpicker/react-fonticonpicker?

在项目目录运行 npm install @fonticonpicker/react-fonticonpicker,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.3.0)、react-dom(^16.3.0)、classnames(^2.2.5)、prop-types(^15.6.1)、react-transition-group(^2.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fonticonpicker/react-fonticonpicker 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fonticonpicker__react-fonticonpicker 是否存在。

@fonticonpicker/react-fonticonpicker 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fonticonpicker/react-fonticonpicker 可以商用吗?

@fonticonpicker/react-fonticonpicker 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fonticonpicker/react-fonticonpicker 的下载量有多少?

根据 npm 官方下载统计,@fonticonpicker/react-fonticonpicker 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,149 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fonticonpicker/react-fonticonpicker 还在维护吗?

最新版本 1.2.0 发布于 2018/10/21(8 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。