Cartesiandocs

Customize

Slots and components

Replace any part of the UI with your own Compose code, and reuse the built-in pieces inside it.

The assistant is assembled from about twenty components. Each one has a slot. If you leave a slot empty, Cartesian draws its own version. If you fill it, your composable is drawn instead, and it receives the same CartesianChatController the built-in one gets.

val slots = CartesianSlots.Builder()
    .productCard { product, controller ->
        MyProductCard(
            product = product,
            inCart = controller.quantityInCart(product.id),
            onAdd = { controller.addToCart(product) },
            onClick = { controller.openProduct(product) },
        )
    }
    .header { controller, onClose ->
        MyHeader(title = controller.assistantName, onClose = onClose)
    }
    .build()

CartesianOptions.Builder().slots(slots).build()

Reuse the defaults

All built-in pieces are public on CartesianComponents. Use them to wrap a default rather than rewrite it:

.assistantMessage { message, controller ->
    Column {
        CartesianComponents.AssistantMessage(message, controller)
        if (message.products.isNotEmpty()) MyLoyaltyPointsBanner(message.products)
    }
}
.composer { controller ->
    Column {
        MyPromoStrip()
        CartesianComponents.Composer(controller)
    }
}
kotlin

Available slots

SlotSignatureDefault
header(controller, onClose)CartesianComponents.Header
connectionStatus(controller)Connecting/offline pill in the header
emptyState(controller)Welcome heading, subtitle and starters
loading(controller)Orb while a past conversation loads
userMessage(message, controller)Right-aligned bubble
assistantMessage(message, controller)The whole answer block (wraps the slots below)
trace(message, controller)Live activity steps
assistantText(message, controller)Markdown answer text
productList(products, controller)Card carousel
productCard(product, controller)One product card
comparison(comparison, controller)Comparison table and recommendation
cartUpdate(update, controller)"Added 2 items to your cart" card
messageActions(message, controller)Copy, thumbs up and down
suggestions(suggestions, controller)Follow-up chips
composer(controller)Input, voice and send/stop
footer(controller)Disclaimer under the composer
drawer(controller)Cart and saved drawer
offline(controller)Full offline state

Composition rules

Slots are nested, not flat

assistantMessage draws trace, assistantText, comparison, productList (which draws productCard), cartUpdate, messageActions and inline suggestions. If you replace assistantMessage without calling CartesianComponents.AssistantMessage, the inner slots are no longer used.

Feature modes still apply

Controller actions follow your feature modes. controller.addToCart calls your listener in Host mode and does nothing in Off mode, so a custom card can't get around a disabled feature.

Read theme values

Inside a slot, use controller.options.theme.colors so your component follows the theme you configured.

Keep slots cheap

Slots recompose while an answer streams. Do heavy work in remember or outside composition.