Codemods

The American Express Design System provides a unified language for designing American Express websites and experiences. The design system provides design resources that match our coded components and are aligned with the American Express brand. Included are colors, components, icons and glyphs, type styles, and graphic assets to get you up and running quickly.

On this page

Back to All Codemods

Tooltip Transform

Converts a v6 Tooltip component to a v7 Tooltip component. Note that this transform exclusively handles migrating the Tooltip component and not the TooltipButton component. The TooltipButton has its own transform for handling the v7 migration separately.

Automatic Changes

  • Renames the open prop to isOpen
  • Removes the forcePlacement prop, which has been deprecated
  • Removes the statusMessage prop, which has been deprecated
  • Removes the info prop, which has been deprecated (see TooltipButton Transform for more information on Info Tooltips)
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Moves the children and other props (excluding aria-expanded and aria-labelledby) into a TooltipContent component
  • Wraps the contents of the triggerElement prop in a TooltipTrigger component
  • Moves aria-expanded and aria-labelledby onto the TooltipTrigger component
  • Migrates the contents of the triggerElement prop as a child of Tooltip

For example:

import { Tooltip } from '@americanexpress/dls-react6';

export default function Page() {

return (

<Tooltip

id="account-tooltip"

triggerElement={

<TooltipButton

info={anyValue}

alternateIconProps={anyValue}

handleTooltipToggle={anyValue}

active={anyValue}

icon={<IconInfo />}

someOtherProp={anyValue}

{...otherProps}

/>

}

placement={placement}

open={open}

info={info}

forcePlacement={anyValue}

statusMessage={anyValue}

aria-expanded={anyValue}

aria-labelledby={anyValue}

theme={{ color: 'red' }}

someOtherProp={anyValue}

{...otherProps}

>

Charles Frost

</Tooltip>

);

}

Transforms into:

import {

Tooltip,

TooltipTrigger,

TooltipContent,

IconButton,

} from '@americanexpress/dls-react';

export default function Page() {

return (

<Tooltip id="account-tooltip" isOpen={isOpen} placement={placement}>

<TooltipTrigger aria-expanded={anyValue} aria-labelledby={anyValue}>

<TooltipButton

info={anyValue}

alternateIconProps={anyValue}

handleTooltipToggle={anyValue}

active={anyValue}

icon={<IconInfo />}

someOtherProp={anyValue}

{...otherProps}

/>

</TooltipTrigger>

<TooltipContent someOtherProp={anyValue} {...otherProps}>

Charles Frost

</TooltipContent>

</Tooltip>

);

}

Manual Changes

State Management

In v7, we’ve updated the Tooltip component to have consistent and predictable controlled/uncontrolled behavior. See TooltipButton Transform for more information on migrating controlled Tooltip components to the new state management API.

Using the Trigger Element to Trigger an Action

In v7, we’ve built each component from the ground up with accessibility in mind. In order to remain compliant with modern accessibility standards, the trigger for a tooltip must not trigger any action other than opening/closing the tooltip. For more information, see the v7 documentation site.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.