Displays a FontAwesome icon.
You should have the chayns-components
package installed. If that is not the
case already, run
yarn add chayns-components
or
npm i chayns-components
After the chayns-components
package is installed, you can import the component
and use it with React:
import React from 'react'
import { Icon } from 'chayns-components';
// ...
<Icon {...} />
The Icon
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
icon | string | { iconName: string, prefix: string } | Array<string> |
✓ | |
className | string |
'' |
|
style | { [key: string]: number | string } |
||
onClick | function |
||
disabled | boolean |
false |
|
stopPropagation | boolean |
false |
icon: string | { iconName: string, prefix: string } | Array<string>;
The icon to display. Supply a string or an array of strings like this:
fa fa-plane
. Search for icons and their strings on
https://fontawesome.com/icons/. For backwards compatibility you can also specify
an icon object from the @fortawesome
-packages, but this should not be used
going forward.
className?: string
A classname string that will be applied to the HTML element of the icon.
style?: { [key: string]: number | string }
A React style object that will be applied ot the <i>
-element of the icon.
onClick?: function
A callback that is called for the onclick
-event on the icon.
disabled?: boolean
Disables any user interaction on the icon and renders it in a disabled style.
stopPropagation?: boolean
Wether to stop propagation of click events to parent elements.