import React from 'react'; import { Icon, InlineIcon, addIcon, addCollection, } from '@iconify/react/dist/offline'; import accountIcon from '@iconify-icons/mdi-light/account'; import alertIcon from '@iconify-icons/mdi-light/alert'; import homeIcon from '@iconify-icons/mdi-light/home'; import presentationPlay from '@iconify-icons/mdi-light/presentation-play'; import checkedIcon from '@iconify-icons/uil/check-circle'; import uncheckedIcon from '@iconify-icons/uil/circle'; import { Checkbox } from './components/Checkbox'; import { InlineDemo } from './components/Inline'; import './App.css'; // Add 'mdi-light:presentation-play' as 'demo' addIcon('demo', presentationPlay); // Add custom icon as 'experiment' addIcon('experiment2', { width: 16, height: 16, body: '', }); // Add icon with id: noto:robot addIcon('noto-robot', { body: '', width: 128, height: 128, }); // Add few mdi-light: icons addCollection({ prefix: 'mdi-light', icons: { 'account-alert': { body: '', }, 'link': { body: '', }, }, width: 24, height: 24, }); // Component class CheckboxIcon extends React.Component { constructor(props) { super(); this.state = { checked: props.checked, }; this._check = this._check.bind(this); } render() { const checked = this.state.checked; const icon = checked ? checkedIcon : uncheckedIcon; const color = checked ? 'green' : 'red'; return ( ); } _check(event) { event.preventDefault(); this.setState({ checked: !this.state.checked, }); } } function App() { // Debug logging for testing references, which cannot be reliably tested with unit tests console.log('References that should be logged: valid icon'); console.log('References that might be logged: missing icon'); console.log('References that should not be logged: missing text icon'); return (

Usage

Empty icon:
Icon referenced by name:
Icon referenced by object:
2 icons imported from icon set:{' '}
Important notice with alert icon!

Checkbox

Tests

Home icon! 24px icon in 16px text with 24px line height, aligned using inline style.

Empty icon (span):
Empty icon (emoji): 😀
Empty icon (em and emoji): empty😀

Clickable icon (testing events and style):

Colored icons (block, inline, block):

Testing reference by adding border to icon:{' '} { console.log('Ref: valid icon'); element.style.border = '1px solid red'; }} />
Reference to missing icon:{' '} { console.log('Ref: missing icon'); element.style.border = '1px solid red'; }} />
Reference to missing icon with fallback text:{' '} { console.log('Ref: missing text icon'); element.style.border = '1px solid red'; }} > 😀

Testing replacing ids in icons: {' '} (default handler) {' '} (string)

); } export default App;