- for engineers, this is the migration guide for
@servicetitan/design-systemto@servicetitan/anvil2, and - for designers, this guide is for the switch from the Anvil Web to Anvil2 Figma library.
Migrating to Anvil2
As of the initial1.0.0 release, there are a few components that are not included that we plan to make available soon. Check out the component mapping guidelines below for more information.
While we work on some of the unreleased components, there is a good chance that upgrading will require using both Anvil1 and Anvil2 for a period of time. Reach out to the Anvil team if you need any assistance or have questions!
React Requirement
To use Anvil2, the consuming project needs to use React 18. Read more about upgrading to React 18 in the Front-End Platform blog.Getting Started Documentation
See our Getting Started page for more details about installing Anvil2 and the basic requirements for using it in an application.Swapping Libraries
- In Figma, enable the Anvil2 library to start using the new components See the Figma docs to learn how to enable a library.
- In code, install the Anvil2 package:
- Once the Anvil2 Web package is installed, components can be imported as follows.
CSS Updates
CSS Utilities
CSS Utility classes have been trimmed down considerably in Anvil2. Many of the classes were rarely (if ever) used, or can be replaced with components like Flex and Grid. At a high level, here is what has changed:- Any utility classes from Anvil1 for flex, grid, display, position, alignment, height, width, z-indexing, border radius, line height, or white space have been removed.
- Spacing classes (margin and padding), now use inline and block properties rather than left/right/top/bottom. This enables easier internationalization using CSS but does require changing the class names. For example,
.m-l-1is now.m-inline-start-1. Learn more in the mdn docs. - Spacing values (
-1,-2, etc.) now useremunits for better accessibility. - Most classes use CSS variables, which are provided by the
ThemeProviderorAnvilProvider. A fallback value is provided for use outside of a provider. - Utility classes can be imported all at once, or by utility type:
There are currently two versions of the CSS Utilities:
utils.css- includes all utility classesa2-utils.css- includes all utility classes prefixed witha2-
a2- prefix, so we recommend using the a2- versions going forward.Component CSS
One important change in Anvil2 is how component CSS is imported and bundled (or, not bundled in this case). In Anvil, a large CSS import that included bundled styles from all components was required. In Anvil2, each component imports its own CSS. Ideally, this means that your application will only bundle the CSS it needs for the Anvil2 components that are included in the app. This also means that consuming applications will only need to directly import CSS from Anvil2 if they are using the CSS Utilities.CSS Modules
Anvil2 also uses CSS Modules to prevent style conflicts and accidental overrides. In general, overriding styles should be avoided to maintain consistency, but in some cases it may still be necessary. To add custom styling to an Anvil2 component, use either aclassName or style object.
Component Updates
We reviewed all of the Anvil1 components and made some significant changes for Anvil2. We trimmed down the library, renamed or repurposed some components, and added a few new ones. The information and links below should help when navigating these changes.Component Mapping
Some components from Anvil1 have been renamed or replaced in Anvil2. The list below includes changes in component names and notes about significant changes from Anvil1 to Anvil2. The following table includes components that have been replaced in Anvil2 and will require some refactoring in consuming projects. Anvil1 components missing from this list have either been removed (see the “Components Omitted in Anvil2” section below) or are still available in Anvil2.| Anvil1 Component | Anvil2 Component |
|---|---|
| Action Menu | Menu |
| BackLink | Drilldown |
| Badge | Chip (The Anvil2 Badge has been repurposed as a notification badge) |
| Banner | Alert |
| Body Text | Text (“body” variant, default) |
| Button Toggle | Segmented Control (Reference doc to be sure your use case matches) |
| Color Picker | Color Field * |
| Data List | DataTable |
| Date Picker | Date Field Single, Date Field Yearless |
| Date Range Picker | Date Field Range |
| Eyebrow | Text (“eyebrow” variant) |
| Headline | Text (“headline” variant) |
| Input | Text Field |
| Modal | Dialog |
| Option List | Listbox or List View |
| Progress Tracker | Stepper |
| Select | Combobox |
| Table | DataTable |
| Tag | Chip |
| Takeover | Dialog (“fullscreen” size) |
| Time Picker | Time Field |
| Toggle Switch | Switch |
| Collapsible | Details |
| Flow Card | Edit Card |
| Togglebox | Select Card |
| Spinner | Spinner |
Roadmap
View the Anvil2 roadmap and upcoming features.
Suggest an idea
Have an idea for a component, pattern, or documentation? Fill out the Feature Request Form in Slack.
Layout in Anvil2
Adjusting layouts has changed in Anvil2. The Flex and Grid components can be used to build layouts using Flexbox and CSS grid properties. These two components can be used in combination with each other along with component-specific layout props, which allows for more flexibility than the Stack and Layout components in the original Anvil1 library.Component Layout Props
On the component-level, most Anvil2 components accept Layout props, which includes several Flex and Grid CSS shortcuts, as well as responsive breakpoint props. Components that do not use Layout props:- Dialog
- Drawer
- Label
- Menu
- Popover
- Toast
- Tooltip
Flex
Create layouts using CSS Flexbox.
Grid
Create layouts using CSS Grid.
Layout props
Apply CSS Flexbox and Grid properties to components.
Other Notable Breaking Changes
Code
The following components may require some refactoring to use in Anvil2.- Announcement
- The
actionNameandonActionClickprops have been removed. Instead, add action buttons aschildrenof theAnnouncement.
- The
Badge/Tag→ Chip- Separate component for
Badgerather than variation of theTag. - Use
labelinstead ofchildren.
- Separate component for
Banner→ Alert- Replace action button props with action buttons in the
childrenof theAlert.
- Replace action button props with action buttons in the
Pickers→ Fields- Coming soon! All picker components (Date Picker, File Picker, etc.) will be replaced with field components.
Modal→ Dialog- The
titleandfooterprops have been replaced with theDialog.HeaderandDialog.Footercomponents, which can be passed aschildrenof theDialog. - Dialog should not be conditionally rendered - use the
openprop to show or hide. Read more about this here.
- The
- Drawer
- Drawer should not be conditionally rendered - use the
openprop to show or hide. Read more about this here.
- Drawer should not be conditionally rendered - use the
Option List→ List View or Listbox- List Views include checkboxes.
- Listboxes are generally used within confined spaces, such as a dropdown or side bar.
- Both components use
childrenrather than theoptionsprop to render items.
Progress Tracker→ Stepper- The
Stepper.Stepsub-components should be children of a Stepper.List. - The
Stepper.List,Stepper.Panel,Stepper.NextButton,Stepper.PrevButton, andStepper.FinalPanelsub-components can be used aschildrenof theStepper.
- The
Select→ Combobox- Combobox allows users to search for one or multiple options within an overlay dropdown.
- Combobox now uses a component-based API to render the list of items. Refer to the Combobox docs for implementation details.
Table→ Data Table (beta)- Data Table has been completely rewritten in Anvil2. Refer to the Data Table docs for more information.
- Tab
- The Anvil2 Tab uses a few sub-components to construct the buttons and panels, and is an uncontrolled component.
- In Anvil2, the
controlsandidprops of theTab.PanelandTab.Buttonare used to determine which panel is opened by which button.
- Toast
- The Anvil2 Toast implementation has undergone a complete overhaul. Rather than using state to control when a toast message is displayed, a set of
toastmethods are available to display, hide, and update toast messages can be used. See the Toast docs to learn how. - The Anvil team and the Front-End Platform team established a holistic solution to avoid issues with using both Anvil1 and Anvil2.
- The Anvil2 Toast implementation has undergone a complete overhaul. Rather than using state to control when a toast message is displayed, a set of
Design
- The Figma library now uses Figma variables to manage styles. This allows for easier text styling usage in addition to native dark mode support.
- Usage of instance swapping in several components, such as Dialog and Drawer, allowing for components to make better use of autolayouts.
- Improved support for suggested content in a component, such as options provided in the Combobox Popover and multiple Tabs in a single instance.
- More consistent application of visual states (e.g., Hover, Active, Focus).
Components Omitted in Anvil2
The following Anvil1 components are no longer available in Anvil2:- Backdrop
- Collapsible
- Mask
- More details
- Select
- Sidebar (integrated into Page)
- Snackbar
Components not currently available
The following components are not currently available in Anvil2, but are under consideration or planned to be released later. The following list is updated quarterly:- Color Picker **
- File Picker **
- Form *
- Inline Edit * Q1 FY27
- Status Light *
Migrate gradually as we release more components
As we work on these components, we expect that consuming projects will need to continue to use Anvil1 components that are not yet released in Anvil2. There should be no issues using Anvil1 alongside Anvil2 until the full catalog of components are available, but please reach out to the Anvil team on Slack if you need assistance.Any net-new designs at ServiceTitan should use Anvil2 going forward. Anvil1 components can be used sparingly when necessary. If an Anvil1 component must be used within a net-new design, plan for a swap via UX Debt.Refer to the Anvil1 docs when using these components. We will keep this migration guide updated as more components become available in Anvil2!