Skip to main content

Common Examples

import { EditCard, EditCardState } from "@servicetitan/anvil2";

const ExampleComponent = () => {
  const [state, setState] = useState<EditCardState>("not started");
  const onChange = (change: EditCardChange) => {
    if (change === "edit") {
      setState("in progress");
    }
    if (change === "save") {
      setState("complete");
    }
    if (change === "cancel") {
      setState("not started");
    }
  };
  return <EditCard state={state} headerText="Header" />;
};

Validation

Saving can be disabled while the contents of the component fail validation.
Last modified on January 23, 2026