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

Buttons Transforms

A series of transforms which convert the following v6 button components into their appropriate v7 components:

  • Button
  • ButtonPrimary
  • ButtonPrimaryDark
  • ButtonSecondary
  • ButtonSecondaryDark
  • ButtonTertiary
  • ButtonTertiaryDark
  • IconButton

Automatic Changes

  • Renames the button variants to Button with the appropriate variant prop:
    • ButtonPrimary -> Button with variant='primary'
    • ButtonPrimaryDark -> Button with variant='primary'
    • ButtonSecondary -> Button with variant='secondary'
    • ButtonSecondaryDark -> Button with variant='secondary'
    • ButtonTertiary -> Button with variant='tertiary'
    • ButtonTertiaryDark -> Button with variant='tertiary'
  • Renames the styleType prop on Button to variant, and adjusts the value as needed:
    • styleType='primary' -> variant='primary'
    • styleType='secondary' -> variant='secondary'
    • styleType='tertiary' -> variant='tertiary'
    • styleType='white' -> variant='primary'
    • styleType='whiteSecondary' -> variant='secondary'
    • styleType='whiteTertiary' -> variant='tertiary'
    • styleType='contextual' -> variant='primary'
  • Renames the IconButton to Button and performs the same adjustments to the styleType prop described above for Button.
  • Changes disabled to aria-disabled.
  • Changes label to aria-label.
  • Renames the loading prop to isLoading.
  • Deletes the theme prop, which has been deprecated. Use the className prop to apply custom styles.
  • Deletes the allowOverflow prop, which has been deprecated. All buttons now overflow by default.
  • Deletes the size prop, which has been deprecated.

For example:

import {

Button,

IconButton,

ButtonSecondaryDark,

} from '@americanexpress/dls-react6';

export default function Page() {

return (

<>

<Button styleType="white" disabled={isDisabled} {...otherProps}>

Some Button

</Button>

<IconButton

styleType="contextual"

icon={<IconAccessibility />}

loading={true}

{...otherProps}

>

Some Button

</IconButton>

<ButtonSecondaryDark

size="sm"

allowOverflow={true}

disabled={isDisabled}

{...otherProps}

>

Some Button

</ButtonSecondaryDark>

</>

);

}

Transforms into:

import { Button } from '@americanexpress/dls-react';

export default function Page() {

return (

<>

<Button variant="primary" aria-disabled={isDisabled} {...otherProps}>

Some Button

</Button>

<Button

variant="primary"

icon={<IconAccessibility />}

isLoading={true}

{...otherProps}

>

Some Button

</Button>

<Button variant="secondary" aria-disabled={isDisabled} {...otherProps}>

Some Button

</Button>

</>

);

}

Manual Changes

Removed Button Variants

Certain button variants have been removed from the DLS and do not have an equivalent replacement in v7. To get the equivalent functionality in v7, first reconsider the use of the component in your application. If the component is still needed, consider customizing the default Button component using the className prop to get the desired functionality.

Button variants removed without an equivalent in v7 include:

  • Button and IconButton with styleType:
    • 'chevron'
    • 'floatingChat'
    • 'floatingScroll'
    • '' (resulted in a ButtonBase component)
  • ButtonBase
  • ButtonChevron
  • ButtonCobrand
  • ButtonFloatingChat
  • ButtonFloatingScroll

Removed
size

The size prop has been removed. In most cases, there is no further action. If your application was previously relying on a button being a specific size, first reconsider the other parts of your application. If a specific size is still needed, the size of the button can be customized using the className prop and adjusting the width and/or height attributes.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.