> ## Documentation Index
> Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Single Recommendation Card – Code

> SingleRecommendationCard presents a single-select choice using radio buttons.

> [!WARNING]
>
> Atlas is deprecated. Use [AI Kit](https://anvil.servicetitan.com/docs/building-agentic-experiences) for any new Atlas experiences.

> [tab] Implementation
>
> ext-atlas-single-recommendation-card-demo
>
> [StackBlitz demo](https://stackblitz.com/github/servicetitan/anvil2-docs-live-code/tree/main/examples/ext-atlas-single-recommendation-card-demo?file=src/App.tsx)
>
> ```tsx lines expandable theme={null}
> import { SingleRecommendationCard } from "@servicetitan/anvil2-ext-atlas";
> import { Card } from "@servicetitan/anvil2";
>
> function App() {
>   return (
>     <Card
>       flexDirection="column"
>       gap={4}
>       background="strong"
>       style={{ width: "388px" }}
>     >
>       <SingleRecommendationCard
>         message="Which service would you like to schedule?"
>         options={[
>           {
>             id: "option1",
>             label: "HVAC Maintenance",
>             description: "Regular maintenance check for your HVAC system",
>           },
>           {
>             id: "option2",
>             label: "Plumbing Repair",
>             description: "Fix any plumbing issues in your home",
>           },
>         ]}
>         actions={[
>           {
>             id: "confirm",
>             name: "Confirm Selection",
>             type: "primary",
>           },
>         ]}
>         onSubmit={(data) => console.log("submitted:", data)}
>       />
>     </Card>
>   );
> }
>
> export default App;
> ```
>
> ## Common Examples
>
> ### Basic Usage
>
> Present a single-select choice:
>
> ```tsx theme={null}
> import { SingleRecommendationCard } from "@servicetitan/anvil2-ext-atlas";
>
> function SingleSelectExample() {
>   const handleSubmit = (response) => {
>     console.log("Selected:", response.optionIds[0]);
>     console.log("Action:", response.actionId);
>   };
>
>   return (
>     <SingleRecommendationCard
>       recommendationId="rec-123"
>       message="Which service would you like to schedule?"
>       options={[
>         { id: "opt-1", label: "HVAC Maintenance", description: "Annual checkup and filter replacement" },
>         { id: "opt-2", label: "Plumbing Inspection", description: "Full system evaluation" },
>         { id: "opt-3", label: "Electrical Review", description: "Safety inspection and testing" },
>       ]}
>       actions={[
>         { id: "confirm", name: "Schedule", type: "primary" },
>         { id: "cancel", name: "Cancel", type: "ghost" },
>       ]}
>       onSubmit={handleSubmit}
>     />
>   );
> }
> ```
>
> ### Submitted State
>
> Show previously selected values:
>
> ```tsx theme={null}
> import { SingleRecommendationCard } from "@servicetitan/anvil2-ext-atlas";
>
> function SubmittedExample() {
>   return (
>     <SingleRecommendationCard
>       recommendationId="rec-123"
>       message="Which service would you like?"
>       options={options}
>       actions={actions}
>       onSubmit={() => {}}
>       submitted={true}
>       selected={["opt-2"]}
>     />
>   );
> }
> ```

> [tab] SingleRecommendationCard API
>
> ```tsx theme={null}
> <SingleRecommendationCard
>   recommendationId="rec-123"
>   message="Select an option"
>   options={[
>     { id: "opt-1", label: "Option 1", description: "Description" },
>   ]}
>   actions={[
>     { id: "submit", name: "Submit", type: "primary" },
>   ]}
>   onSubmit={handleSubmit}
>   submitted={false}
>   selected={[]}
> />
> ```
>
> ## `SingleRecommendationCard` Props
>
> **actions** `RecommendationAction[]` *required*
>
> Array of action buttons with `id`, `name`, and optional `type`.
>
> **message** `string` *required*
>
> The prompt message to display above the options.
>
> **onSubmit** `(response: ConfirmationResponse) =\> void` *required*
>
> Callback fired when an action button is clicked. Receives `sourceMessageId`, `optionIds`, and `actionId`.
>
> **options** `Options[]` *required*
>
> Array of selectable options with `id`, `label`, and optional `description`.
>
> **recommendationId** `string`
>
> Unique identifier for this recommendation, included in the submit response.
>
> **selected** `string[]`
>
> Array of selected option IDs to display when `submitted` is true.
>
> **submitted** `boolean` (default: false)
>
> When true, disables all inputs and shows the selected state.

> [tab] Shared Types
>
> ## Options Interface
>
> ```tsx theme={null}
> interface Options {
>   id: string;
>   label: string;
>   description?: string;
>   value?: string;
> }
> ```
>
> ## RecommendationAction Interface
>
> ```tsx theme={null}
> interface RecommendationAction {
>   id: string;
>   name: string;
>   type?: "primary" | "secondary" | "ghost" | "danger" | "link";
>   url?: string;
> }
> ```
>
> ## ConfirmationResponse Interface
>
> ```tsx theme={null}
> interface ConfirmationResponse {
>   sourceMessageId?: string;
>   optionIds: string[];
>   actionId: string;
>   parameters?: Record<string, string | number | undefined>;
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.