Custom Components
Carousel

About
The Carousel component provides a horizontally scrollable container for displaying multiple cards or items. It's designed to work seamlessly with CustomCard components to create interactive, scrollable content galleries.
Properties
Carousel Properties
The Carousel component accepts these properties:
Property | Type | Required | Description |
---|---|---|---|
children | ReactNode | Yes | Content to be rendered inside the carousel |
Import and Basic Usage
You can import the Carousel component from touchpoint once the package has been installed or made available in your project.
Define onClick
When using Carousel with CustomCard components, define click handlers on the individual cards to handle user interactions. The Carousel itself is a container component.
Access the ConversationHandler method
sendChoice
via conversationHandler.sendChoice
to send the user's choice back to NLX.
Read more details about building Custom Components with Touchpoint in the Getting started with Touchpoint components documentation page.
Example
The Carousel component is best used with multiple CustomCard components to create a scrollable interface.
Example Modality Schema
1[ 2 { 3 "id": "uuid", 4 "thumbnail": "imageUrl", 5 "label": "Label text", 6 "value": "Value text" 7 } 8]
Example Carousel Component
1<script type="module"> 2 import { create, React, html } from "https://unpkg.com/@nlxai/touchpoint-ui@1.0.5-alpha.12/lib/index.js?module"; 3 4 const ItemsCarousel = ({ data, conversationHandler }) => { 5 const [selectedItemId, setSelectedItemId] = React.useState(null); 6 7 return html`32`; 33 }; 34 35 // Register component when creating touchpoint 36 const touchpoint = await create({ 37 config: { 38 applicationUrl: "YOUR_APPLICATION_URL", 39 headers: { "nlx-api-key": "YOUR_API_KEY" }, 40 languageCode: "en-US", 41 }, 42 customModalities: { 43 ItemsCarouselModality: ItemsCarousel, 44 }, 45 }); 46 47</script>
Related Components
- Custom Cards for card components used within carousels
- Typography for text styling within cards
- Icons for visual elements in cards
- Building Components without JSX