@fortawesome/react-fontawesome

  • Version 3.1.0
  • Published
  • 88.5 kB
  • No dependencies
  • MIT license

Install

npm i @fortawesome/react-fontawesome
yarn add @fortawesome/react-fontawesome
pnpm add @fortawesome/react-fontawesome

Overview

Official React component for Font Awesome

Index

Variables

variable FontAwesomeIcon

const FontAwesomeIcon: React.ForwardRefExoticComponent<any>;
  • FontAwesomeIcon component.

Functions

function FontAwesomeLayers

FontAwesomeLayers: ({
children,
className,
size,
...attributes
}: FontAwesomeLayersProps) => react_jsx_runtime.JSX.Element;
  • React Component that allows you to stack multiple Font Awesome icons on top of each other, or to layer with text or a counter.

    Example 1

    import { FontAwesomeIcon, FontAwesomeLayers } from '@fortawesome/react-fontawesome'
    import { faBookmark, faCircle, faCheck, faHeart, faMoon, faPlay, faStar, faSun } from '@fortawesome/free-solid-svg-icons'
    // React versions of the examples from the FontAwesome Web Docs
    export const Examples = () => (
    <div className="fa-4x">
    <FontAwesomeLayers>
    <FontAwesomeIcon icon={faCircle} color="tomato" />
    <FontAwesomeIcon icon={faCheck} inverse transform="shrink-6" />
    </FontAwesomeLayers>
    <FontAwesomeLayers>
    <FontAwesomeIcon icon={faBookmark} />
    <FontAwesomeIcon icon={faHeart} color="tomato" transform="shrink-10 up-2" />
    </FontAwesomeLayers>
    <FontAwesomeLayers>
    <FontAwesomeIcon icon={faPlay} transform="rotate--90 grow-4" />
    <FontAwesomeIcon icon={faSun} inverse transform="shrink-10 up-2" />
    <FontAwesomeIcon icon={faMoon} inverse transform="shrink-11 down-4.2 left-4" />
    <FontAwesomeIcon icon={faStar} inverse transform="shrink-11 down-4.2 right-4" />
    </FontAwesomeLayers>
    </div>
    )

    For examples using Text or Counter components:

    See Also

function LayersCounter

LayersCounter: ({
count,
className,
style,
...attributes
}: any) => React.JSX.Element;
  • Counter component to be used within a FontAwesomeLayers component.

    Example 1

    import { FontAwesomeLayers, LayersCounter } from '@fortawesome/react-fontawesome'
    import { faEnvelope } from '@fortawesome/free-solid-svg-icons'
    // React version of the example from the FontAwesome Web Docs
    export const Example = ({ count = 1419 }) => (
    <FontAwesomeLayers size="4x">
    <FontAwesomeIcon icon={faEnvelope} />
    <LayersCounter count={count.toLocaleString()} style={{ backgroundColor: 'tomato' }} />
    </FontAwesomeLayers>
    )

    See Also

    • https://docs.fontawesome.com/web/style/layer

function LayersText

LayersText: ({
text,
className,
inverse,
transform,
style,
...attributes
}: any) => React.JSX.Element;
  • Text component to be used within a FontAwesomeLayers component.

    Example 1

    import { FontAwesomeLayers, LayersText } from '@fortawesome/react-fontawesome'
    import { faCalendar, faCertificate } from '@fortawesome/free-solid-svg-icons'
    // React versions of the examples from the FontAwesome Web Docs
    export const Examples = () => (
    <div className="fa-4x">
    <FontAwesomeLayers>
    <FontAwesomeIcon icon={faCalendar} />
    <LayersText
    text="27"
    inverse
    style={{ fontWeight: '900' }}
    transform="shrink-8 down-3"
    />
    </FontAwesomeLayers>
    <FontAwesomeLayers>
    <FontAwesomeIcon icon={faCertificate} />
    <LayersText
    text="NEW"
    inverse
    style={{ fontWeight: '900' }}
    transform="shrink-11.5 rotate--30"
    />
    </FontAwesomeLayers>
    </div>
    )

    See Also

    • https://docs.fontawesome.com/web/style/layer

Interfaces

interface AnimationProps

interface AnimationProps {}

    property beat

    beat?: boolean | undefined;

    property beatFade

    beatFade?: boolean | undefined;

    property bounce

    bounce?: boolean | undefined;

    property fade

    fade?: boolean | undefined;

    property pulse

    pulse?: boolean | undefined;

    property shake

    shake?: boolean | undefined;

    property spin

    spin?: boolean | undefined;

    property spinPulse

    spinPulse?: boolean | undefined;

    property spinReverse

    spinReverse?: boolean | undefined;

    interface FontAwesomeIconProps

    interface FontAwesomeIconProps
    extends AnimationProps,
    TransformProps,
    Omit<SVGAttributes<SVGSVGElement>, 'children' | 'mask' | 'transform'>,
    RefAttributes<SVGSVGElement> {}

      property border

      border?: boolean | undefined;

      property className

      className?: string | undefined;
      • Any additional CSS classes to apply to the icon

      property color

      color?: string | undefined;
      • The color of the icon. Can be any valid CSS color value

      property fixedWidth

      fixedWidth?: boolean | undefined;
      • See Also

        Deprecated

        7.0.0

        Starting in FontAwesome 7.0.0, all icons are fixed width by default. This property will be removed in a future version.

        If you want to remove the fixed width to replicate the behavior of previous versions, you can set the new widthAuto property to true.

      property icon

      icon: IconProp;

      property inverse

      inverse?: boolean | undefined;

      property mask

      mask?: IconProp | undefined;

      property maskId

      maskId?: string | undefined;
      • Accessibility ID for the mask element

      property size

      size?: SizeProp | undefined;
      • The size of the icon from a predefined set of sizes.

      property style

      style?: (CSSProperties & CSSVariables) | undefined;
      • Any custom styles or CSS variable overrides for the icon element.

      property swapOpacity

      swapOpacity?: boolean | undefined;

      property tabIndex

      tabIndex?: number | undefined;

        property title

        title?: string | undefined;
        • An accessibility title for the icon to be read by screen-readers or assistive technologies.

        property titleId

        titleId?: string | undefined;
        • A unique ID for the accessibility title element.

        property widthAuto

        widthAuto?: boolean | undefined;

        interface TransformProps

        interface TransformProps {}

          property flip

          flip?: FlipProp | boolean | undefined;
          • Flip the icon horizontally, vertically or both.

          property listItem

          listItem?: boolean | undefined;
          • Example 1

            <ul className='fa-ul'>
            <li>
            <span className='fa-li'>
            <FontAwesomeIcon icon={['fas', 'check']} />
            </span>
            List item with icon
            </li>
            </ul>

            See Also

            Deprecated

            Simply wrap the icon instead, no need to pass this property.

          property pull

          pull?: PullProp | undefined;
          • Wrap text around the icon by pulling it left or right.

          property rotateBy

          rotateBy?: boolean | undefined;
          • Custom rotation is used to rotate the icon by a specific number of degrees, rather than the standard 90, 180, or 270 degrees available in the rotation property.

            To use this feature, set rotateBy to true and provide a CSS variable --fa-rotate-angle with the desired rotation angle in degrees.

            Example 1

            <FontAwesomeIcon
            icon="fa-solid fa-coffee"
            rotateBy
            style={{ '--fa-rotate-angle': '329deg' }}
            />

            See Also

          property rotation

          rotation?: RotateProp | undefined;

          property symbol

          symbol?: FaSymbol | undefined;

          property transform

          transform?: string | Transform | undefined;

          Package Files (1)

          Dependencies (0)

          No dependencies.

          Dev Dependencies (49)

          Peer Dependencies (2)

          Badge

          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@fortawesome/react-fontawesome.

          • Markdown
            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@fortawesome/react-fontawesome)
          • HTML
            <a href="https://www.jsdocs.io/package/@fortawesome/react-fontawesome"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>