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.

Back to All Codemods

ToggleSwitch Transform

Converts a v6 ToggleSwitch component to a v7 ToggleSwitch component.

Automatic Changes

  • Renames the disabled prop to aria-disabled prop.
  • Deletes the srLabelToggleOn which has been deprecated. Use the onText and hideToggleStatus props to customize the on text and whether it is shown.
  • Deletes the srLabelToggleOff which has been deprecated. Use the offText and hideToggleStatus props to customize the off text and whether it is shown.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.

For example:

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

export default function Page() {

return (

<ToggleSwitch

aria-labelledby="toggle-label"

disabled={isDisabled}

srLabelToggleOn="On"

srLabelToggleOff="Off"

theme={{ color: 'red' }}

{...otherProps}

/>

);

}

Transforms into:

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

export default function Page() {

return (

<ToggleSwitch

aria-labelledby="toggle-label"

aria-disabled={isDisabled}

{...otherProps}

/>

);

}

Manual Changes

Label

A visual label is required. Use the label prop or provide a custom label using the aria-labelledby prop.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.