An icon is a graphic symbol that represents an object (ie a file) or a function. They can be used to give the user feedback.
import React from 'react' import Icon from 'playbook-ui' const IconRotate = (props) => { return ( <div> <Icon fixedWidth icon="user" rotation={90} size="2x" /> <Icon fixedWidth icon="user" rotation={180} size="2x" /> <Icon fixedWidth icon="user" rotation={270} size="2x" /> </div> ) } export default IconRotate
import React from 'react' import Icon from 'playbook-ui' const IconFlip = (props) => { return ( <div> <Icon fixedWidth flip="horizontal" icon="question-circle" size="2x" /> <Icon fixedWidth flip="vertical" icon="question-circle" size="2x" /> <Icon fixedWidth flip="both" icon="question-circle" size="2x" /> </div> ) } export default IconFlip
A spinner icon can show a user that something is loading or saving.
import React from 'react' import Icon from 'playbook-ui' const IconAnimate = (props) => { return ( <div> <p> <Icon fixedWidth icon="spinner" size="2x" spin /> {' '} <span>{'Spin'}</span> </p> <br /> <p> <Icon fixedWidth icon="spinner" pulse size="2x" /> {' '} <span>{'Pulse'}</span> </p> </div> ) } export default IconAnimate
Icon Pull can be used to indicate that the user can perform a pull action.
import React from 'react' import Icon from 'playbook-ui' const IconSizes = (props) => { return ( <div> <p> <Icon icon="user" size="lg" /> {' '} <span>{'Large'}</span> </p> <p> <Icon icon="user" size="sm" /> {' '} <span>{'Small'}</span> </p> <p> <Icon icon="user" size="xs" /> {' '} <span>{'XSmall'}</span> </p> <br /> <br /> <p> <Icon icon="user" size="1x" /> {' '} <span>{'1x'}</span> </p> <p> <Icon icon="user" size="2x" /> {' '} <span>{'2x'}</span> </p> <p> <Icon icon="user" size="3x" /> {' '} <span>{'3x'}</span> </p> <p> <Icon icon="user" size="4x" /> {' '} <span>{'4x'}</span> </p> <p> <Icon icon="user" size="5x" /> {' '} <span>{'5x'}</span> </p> <p> <Icon icon="user" size="6x" /> {' '} <span>{'6x'}</span> </p> <p> <Icon icon="user" size="7x" /> {' '} <span>{'7x'}</span> </p> <p> <Icon icon="user" size="8x" /> {' '} <span>{'8x'}</span> </p> <p> <Icon icon="user" size="9x" /> {' '} <span>{'9x'}</span> </p> <p> <Icon icon="user" size="10x" /> {' '} <span>{'10x'}</span> </p> </div> ) } export default IconSizes
When using custom icons it is important to introduce a "clean" SVG. In order to ensure these custom icons perform as intended within your kit(s), ensure these things have been modified from the original SVG markup:
Attributes must be React compatible e.g. xmlns:xlink
should be xmlnsXlink
and so on. There should be no hyphenated attributes and no semi-colons!.
Fill colors with regards to g
or path
nodes, e.g. fill="black"
, should be replaced with currentColor
ala fill="currentColor"
. Your mileage may vary depending on the complexity of your SVG.
Pay attention to your custom icon's dimensions and viewBox
attribute. It is best to use a viewBox="0 0 512 512"
starting point when designing instead of trying to retrofit the viewbox afterwards!
You must source your own SVG into component/view you are working on. This can easily be done in programmatic and maintainable ways.
So long as you have a valid React <SVG>
node, you can send it as the customIcon
prop and the kit will take care of the rest.
Some Rails applications use only webpack(er) which means using image_url
will be successful over image_path
in most cases especially development where Webpack Dev Server is serving assets over HTTP. Rails applications still using Asset Pipeline may use image_path
or image_url
. Of course, YMMV depending on any custom configurations in your Rails application.
import React from 'react' import { Icon } from 'playbook-ui' // import Icons as config from 'power-icons' const config = { moon: ( <svg ariaHidden="true" focusable="false" role="img" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" > <path d="M448 0H64C28.7 0 0 28.7 0 64v288c0 35.3 28.7 64 64 64h96v84c0 7.1 5.8 12 12 12 2.4 0 4.9-.7 7.1-2.4L304 416h144c35.3 0 64-28.7 64-64V64c0-35.3-28.7-64-64-64zm16 352c0 8.8-7.2 16-16 16H288l-12.8 9.6L208 428v-60H64c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16h384c8.8 0 16 7.2 16 16v288zM336 184h-56v-56c0-8.8-7.2-16-16-16h-16c-8.8 0-16 7.2-16 16v56h-56c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16h56v56c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16v-56h56c8.8 0 16-7.2 16-16v-16c0-8.8-7.2-16-16-16z" fill="currentColor" /> </svg> ), } const IconCustom = (props) => { return ( <div> <Icon customIcon={config.moon} size="7x" /> </div> ) } export default IconCustom
Our Icon kit allows integration with FontAwesome's custom kit functionality out-of-the-box.
All you need to do is 3 things:
1) Import your custom-icon.js file as outlined in the FontAwesome docs.
2) Use our fontStyle prop called "fak" so that our Icon component knows you are using a "fa-kit" icon.
3) Pass in your FaKit name as a string to our icon prop (This is the name that you designated when you uploaded the icon on their site).
Be careful of use cases where there should be a clickable area around the icon. Icon Circle Button may need to be used instead.