# Templates

The AIPrompt allows you to control the appearance of the prompt suggestion and view items by using template options.

For more information on the capabilities and syntax of the templates, see the [Using Client Templates](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/helper-basics/using-client-templates) article. For a runnable example, refer to the [demo on customizing the templates in the AIPrompt](https://demos.telerik.com/aspnet-mvc/aiprompt/templates).

## Prompt Suggestion Items Template

The list of prompt suggestions is displayed in the `Prompt` view. You can customize the appearance of the suggestion items through different template methods like `PromptSuggestionItemTemplate()`, `PromptSuggestionItemTemplateHandler()`, and `PromptSuggestionItemTemplateId()`.

The following example demonstrates how to use the `PromptSuggestionItemTemplateHandler()` option to style each prompt suggestion item based on its content.

```Razor HtmlHelper
    @(Html.Kendo().AIPrompt()
        .Name("aiprompt")
        .PromptSuggestionItemTemplateHandler("promptSuggestionTemplate")
        .Views(views =>
        {
            views.Add().Type(ViewType.Prompt)
            .PromptSuggestions(new string[] { "Out of office (contact colleague)", "LinkedIn post for work/life balance and well-being" });
            views.Add().Type(ViewType.Output);
        })
    )
```

```JS scripts
<script>
    var promptSuggestionsData = [
    {
        suggestion: "Out of office (contact colleague)",
        color:"yellow",
        background: "red"
    },
    {
        suggestion: "LinkedIn post for work/life balance and well-being",
        color: "darkgreen",
        background: "lightblue"
    }];

    function promptSuggestionTemplate(data) {
        let suggestionText = data.suggestion;
        let getSuggestionData = $.grep(promptSuggestionsData, function (item) {
            return item.suggestion == suggestionText;
        });
        return `<span role="listitem" class="k-suggestion" style="color:${getSuggestionData[0].color}; background-color: ${getSuggestionData[0].background}">${getSuggestionData[0].suggestion}</span>`;
    }
</script>
```

## Output Items Template

Use the `OutputTemplate()` option to control how each generated output card is rendered in the `Output` view. The specified template is applied after the output has finished streaming to render the final content.

The option has a various overloads like `OutputTemplateHandler()`, `OutputTemplateId()`, `OutputTemplate()` that accepts a [Template component](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/template/overview), and `OutputTemplateView()`.

The following example demonstrates how to customize the default appearance of the output cards.

```Razor HtmlHelper
@(Html.Kendo().AIPrompt()
    .Name("aiprompt")
    .OutputTemplateHandler("outputTemplate")
    ... // Additional configuration.
)
```

```JS scripts
<script>
    function outputTemplate({output, content}) {
        return `<div class="ai-response">
                    <small>Prompt: ${kendo.htmlEncode(output.prompt)}</small><br/>
                    <strong>AI:</strong> ${content}
                </div>`;
    }
</script>
```

## View Content Templates

The AIPrompt supports custom views through the `Views()` configuration. By using the `ViewTemplate()` and the `FooterTemplate()` methods, you can specify the content and footer of that custom view.

The following example demonstrates how to add a custom view in the AIPrompt component.

```Razor HtmlHelper
    @(Html.Kendo().AIPrompt()
        .Name("aiprompt")
        .Views(views =>
        {
            views.Add().Type(ViewType.Custom).Name("myCustomView")
            .ButtonText("Additional options")
            .ViewTemplate("<div><p>Custom View content</p></div>")
            .FooterTemplate("<div class='custom-footer'>Custom View footer</div>");
        })
    )
```

## See Also

* [Templates in the AIPrompt for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/aiprompt/templates)
* [Using Client Templates](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/helper-basics/using-client-templates)
