Skip to main content
Version: 3.10.0-beta.32 (Latest)

Icons

Migration Guide: Icon Component Updates​

General Overview​

This migration involves changes to how icons are used within the OHIF platform. The core change is the move to a new icon component library, @ohif/ui-next, which provides more flexibility and a more consistent naming convention for icons.

Key Changes:

  1. New Icon Library: The primary change is the shift from using <Icon> from @ohif/ui to using the new Icons component from @ohif/ui-next.
  2. AbcDef Naming Convention: The new library uses a AbcDef (PascalCase) naming convention for the icons. For instance, status-alert is now StatusAlert.
  3. Legacy Fallback: To ease the transition, a legacy fallback has been provided using Icons.ByName. This allows you to continue using the old name="status-alert" format but is not the recommended way moving forward.
  4. Direct Icon Component Access: The recommended approach is to use Icons.StatusAlert instead of <Icons.ByName name="status-alert"/> this way will make code more clear and readable.

Migration Strategies​

You have two ways to approach the migration:

  1. Recommended Approach (Gradual Adoption):

    • Start by updating your codebase to use the Icons.Method for the new icon naming convention.
    • For example, replace <Icon name="status-alert" /> with <Icons.StatusAlert />.
    • This ensures your code is aligned with the new standard and provides optimal compatibility in the future.
    • This method can be rolled out in phases.
  2. Legacy Fallback Approach (Temporary):

    • If a full migration is not immediately feasible, you can use the legacy fallback temporarily:
      • Replace <Icon name="status-alert" /> with <Icons.ByName name="status-alert" />.
    • This option allows you to complete the migration with minimal disruption to the old code
    • However, it is highly recommended to move towards the Icons.Method approach to take advantage of all the new library offers and have a cleaner code base.

Recommendation: We strongly recommend using the Recommended Approach for a more maintainable and consistent codebase going forward.

Specific Changes (Code Examples)​

Here are some specific examples based on the diff you provided, illustrating both the legacy fallback and recommended approach:

Example 1: Status Icons in _getStatusComponent.tsx

Old Code (@ohif/ui):

import { Icon, Tooltip } from '@ohif/ui';

// ...
case true:
StatusIcon = () => <Icon name="status-alert" />;
break;
case false:
StatusIcon = () => (
<Icon
className="text-aqua-pale"
name="status-untracked"
/>
);
break;
//...

Legacy Fallback Approach (Icons.ByName):

import { Tooltip } from '@ohif/ui';
import { Icons } from '@ohif/ui-next';

// ...
case true:
StatusIcon = () => <Icons.ByName name="status-alert" />;
break;
case false:
StatusIcon = () => (
<Icons.ByName
className="text-aqua-pale"
name="status-untracked"
/>
);
break;
//...

Recommended Approach (Icons.StatusAlert, Icons.StatusUntracked):

import { Tooltip } from '@ohif/ui';
import { Icons } from '@ohif/ui-next';

// ...
case true:
StatusIcon = () => <Icons.StatusAlert />;
break;
case false:
StatusIcon = () => (
<Icons.StatusUntracked
className="text-aqua-pale"
/>
);
break;
//...

Example 5: Icon usage in WorkList.tsx

Old Code (@ohif/ui):

   <Icon
name="group-layers"

Recommended Approach (Icons.GroupLayers):

    <Icons.GroupLayers
   <Icons.ByName
className="!h-[20px] !w-[20px] text-black"
name={isValidMode ? 'launch-arrow' : 'launch-info'}
/>

Recommended Approach (Icons.LaunchArrow, Icons.LaunchInfo):

     isValidMode ? (
<Icons.LaunchArrow className="!h-[20px] !w-[20px] text-black" />
) : (
<Icons.LaunchInfo className="!h-[20px] !w-[20px] text-black" />
)

Detailed Renaming Table​

Old Icon NameNew Icon Component NameExample Usage (Icons.)Notes
status-alertStatusAlertIcons.StatusAlert
status-untrackedStatusUntrackedIcons.StatusUntracked
status-lockedStatusLockedIcons.StatusLocked
icon-transferringIconTransferringIcons.IconTransferring
icon-alert-smallAlertIcons.Alert
icon-alert-outlineAlertOutlineIcons.AlertOutline
icon-status-alertAlertIcons.Alert
action-new-dialogActionNewDialogIcons.ActionNewDialog
VolumeRenderingVolumeRenderingIcons.VolumeRendering
chevron-leftChevronClosedIcons.ChevronClosedUse when arrow direction needs to point left
chevron-downChevronOpenIcons.ChevronOpenUse when arrow direction needs to point down
launch-arrowLaunchArrowIcons.LaunchArrow
launch-infoLaunchInfoIcons.LaunchInfo
group-layersGroupLayersIcons.GroupLayers
icon-uploadUploadIcons.Upload
icon-searchSearchIcons.Search
icon-clear-fieldClearIcons.Clear
icon-addAddIcons.Add
icon-closeCloseIcons.Close
icon-pausePauseIcons.Pause
icon-playPlayIcons.Play
icon-multiple-patientsMultiplePatientsIcons.MultiplePatients
icon-settingsSettingsIcons.Settings
icon-more-menuMoreIcons.More
content-prevContentPrevIcons.ContentPrev
content-nextContentNextIcons.ContentNext
checkbox-checkedCheckBoxCheckedIcons.CheckBoxChecked
checkbox-uncheckedCheckBoxUncheckedIcons.CheckBoxUnchecked
checkbox-defaultCheckBoxUncheckedIcons.CheckBoxUnchecked
checkbox-activeCheckBoxCheckedIcons.CheckBoxChecked
sorting-active-upSortingAscendingIcons.SortingAscending
sorting-active-downSortingDescendingIcons.SortingDescending
sortingSortingIcons.Sorting
linkLinkIcons.Link
unlinkLinkIcons.Link
info-actionInfoIcons.Info
databaseDatabaseIcons.Database
tool-3d-rotateTool3DRotateIcons.Tool3DRotate
tool-angleToolAngleIcons.ToolAngle
tool-annotateToolAnnotateIcons.ToolAnnotate
tool-bidirectionalToolBidirectionalIcons.ToolBidirectional
tool-calibrationToolCalibrateIcons.ToolCalibrate
tool-captureToolCaptureIcons.ToolCapture
tool-cineToolCineIcons.ToolCine
tool-circleToolCircleIcons.ToolCircle
tool-cobb-angleToolCobbAngleIcons.ToolCobbAngle
tool-create-thresholdToolCreateThresholdIcons.ToolCreateThreshold
tool-crosshairToolCrosshairIcons.ToolCrosshair
dicom-tag-browserToolDicomTagBrowserIcons.ToolDicomTagBrowser
tool-flip-horizontalToolFlipHorizontalIcons.ToolFlipHorizontal
tool-freehand-polygonToolFreehandPolygonIcons.ToolFreehandPolygon
tool-freehand-roiToolFreehandRoiIcons.ToolFreehandRoi
tool-freehandToolFreehandIcons.ToolFreehand
tool-fusion-colorToolFusionColorIcons.ToolFusionColor
tool-invertToolInvertIcons.ToolInvert
tool-layout-defaultToolLayoutDefaultIcons.ToolLayoutDefault
tool-lengthToolLengthIcons.ToolLength
tool-magnetic-roiToolMagneticRoiIcons.ToolMagneticRoi
tool-magnifyToolMagnifyIcons.ToolMagnify
tool-measure-ellipseToolMeasureEllipseIcons.ToolMeasureEllipse
tool-more-menuToolMoreMenuIcons.ToolMoreMenu
tool-moveToolMoveIcons.ToolMove
tool-polygonToolPolygonIcons.ToolPolygon
tool-quick-magnifyToolQuickMagnifyIcons.ToolQuickMagnify
tool-rectangleToolRectangleIcons.ToolRectangle
tool-referenceLinesToolReferenceLinesIcons.ToolReferenceLines
tool-resetToolResetIcons.ToolReset
tool-rotate-rightToolRotateRightIcons.ToolRotateRight
tool-seg-brushToolSegBrushIcons.ToolSegBrush
tool-seg-eraserToolSegEraserIcons.ToolSegEraser
tool-seg-shapeToolSegShapeIcons.ToolSegShape
tool-seg-thresholdToolSegThresholdIcons.ToolSegThreshold
tool-spline-roiToolSplineRoiIcons.ToolSplineRoi
tool-stack-image-syncToolStackImageSyncIcons.ToolStackImageSync
tool-stack-scrollToolStackScrollIcons.ToolStackScroll
tool-toggle-dicom-overlayToolToggleDicomOverlayIcons.ToolToggleDicomOverlay
tool-ultrasound-bidirectionalToolUltrasoundBidirectionalIcons.ToolUltrasoundBidirectional
tool-window-levelToolWindowLevelIcons.ToolWindowLevel
tool-window-regionToolWindowRegionIcons.ToolWindowRegion
tool-zoomToolZoomIcons.ToolZoom
tool-layoutToolLayoutIcons.ToolLayout
icon-tool-eraserToolEraserIcons.ToolEraser
icon-tool-brushToolBrushIcons.ToolBrush
icon-tool-thresholdToolThresholdIcons.ToolThreshold
icon-tool-shapeToolShapeIcons.ToolShape
icon-color-lutIconColorLUTIcons.IconColorLUT
viewport-window-levelViewportWindowLevelIcons.ViewportWindowLevel
notifications-infoNotificationInfoIcons.NotificationInfo
layout-advanced-3d-four-upLayoutAdvanced3DFourUpIcons.LayoutAdvanced3DFourUp
layout-advanced-3d-mainLayoutAdvanced3DMainIcons.LayoutAdvanced3DMain
layout-advanced-3d-onlyLayoutAdvanced3DOnlyIcons.LayoutAdvanced3DOnly
layout-advanced-3d-primaryLayoutAdvanced3DPrimaryIcons.LayoutAdvanced3DPrimary
layout-advanced-axial-primaryLayoutAdvancedAxialPrimaryIcons.LayoutAdvancedAxialPrimary
layout-advanced-mprLayoutAdvancedMPRIcons.LayoutAdvancedMPR
layout-common-1x1LayoutCommon1x1Icons.LayoutCommon1x1
layout-common-1x2LayoutCommon1x2Icons.LayoutCommon1x2
layout-common-2x2LayoutCommon2x2Icons.LayoutCommon2x2
layout-common-2x3LayoutCommon2x3Icons.LayoutCommon2x3
illustration-investigational-useInvestigationalUseIcons.InvestigationalUse