views/carousel.tsx
Fit the Available Space
useLayout reports the room the host gives the view: maxHeight, and the safeArea insets that keep content clear of device notches and the chat composer.
views/carousel.tsx
maxHeight and pads its bottom by safeArea.insets.bottom, so the last row clears the composer instead of hiding behind it.
Match the Theme
useLayout reports the host’s color scheme as theme, "light" or "dark". A view on its own palette looks pasted into the conversation; read theme and follow it.
views/carousel.tsx
dark class when the host is dark, the convention Tailwind’s dark: variants key off, so its styles track the host.
Respond to the Display Mode
useDisplayMode returns the current mode and a setter. The three modes give the view different room and purpose:
inlineis the default: a compact panel embedded in the conversation. The smallest surface, so it suits a single result or a short list.fullscreentakes over the surface for richer, multi-step tasks.pip(picture in picture) floats above the conversation and stays open, which fits live or changing content. On mobile it coerces to fullscreen.
views/carousel.tsx
Adapt to the User
useUser reports the locale and the userAgent: the device type, and whether it supports hover and touch.
views/carousel.tsx
capabilities.hover before relying on hover affordances, and locale to translate copy.
Iterate
The DevTools environment inspector flips theme, display mode, locale, and device type live, so you can watch the view adapt on localhost, then confirm it in a real host through the tunnel.Go Further
Create Views
Craft interactive UIs rendered in conversation
Handle Files
Move files in and out of your app
Configure CSP
Let your views reach the domains they need