Icons
import {Icon} from 'cx/widgets';The Icon is used to render icons.
| Property | Description | Type |
|---|---|---|
name | Name under which the icon is registered. | string |
baseClass | Base CSS class to be applied to the element. Default is | string |
class | Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list. | string/object |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
Registering Icons
Cx includes only a couple of icons. Additional icon sets need to be registered.
The following example shows how to register FontAwesome icon set.
registerFactory
Icon.registerFactory((name, props) => {
props = { ...props };
props.className = `fa fa-${name} ${props.className || ''}`;
return <i {...props} />
});Individual icons can be registered using Icon.register method.