Component Overview
TheAdMeshLayout
component is the main UI component for displaying AdMesh recommendations. It automatically adapts to different content types and provides multiple layout options.
Basic Usage
Layout Types
Auto Layout
Auto Layout
Automatically selects the best layout based on content and context.When to use:
- Default choice for most applications
- When you want the component to decide the best presentation
- For dynamic content where recommendation types may vary
- 1-2 recommendations: Uses list layout
- 3-4 recommendations: Uses grid layout
- 5+ recommendations: Uses grid with pagination
- Citation context: Uses citation layout
Grid Layout
Grid Layout
Displays recommendations in a responsive card grid.Features:
- Responsive grid (1-4 columns based on screen size)
- Card-based design with hover effects
- Shows pricing, features, and ratings
- Perfect for product showcases
- E-commerce recommendations
- Product comparison pages
- Landing pages with multiple options
- When you have 3+ recommendations
List Layout
List Layout
Displays recommendations in a vertical list format.Features:
- Compact vertical layout
- Detailed information display
- Easy scanning and comparison
- Mobile-friendly design
- Detailed product comparisons
- Mobile applications
- Sidebar recommendations
- When space is limited
Citation Layout
Citation Layout
Inline citations perfect for AI assistants and conversational interfaces.Features:
- Inline text-based format
- Minimal visual footprint
- Contextual integration
- Natural conversation flow
- AI chatbots and assistants
- Conversational interfaces
- Inline content recommendations
- Text-heavy applications
Props Reference
Required Props
Prop | Type | Description |
---|---|---|
recommendations | Recommendation[] | Array of recommendation objects from AdMesh API |
Optional Props
Prop | Type | Default | Description |
---|---|---|---|
layout | 'auto' | 'grid' | 'list' | 'citation' | 'auto' | Layout type to use |
onRecommendationClick | (adId: string, admeshLink: string) => void | undefined | Click handler for recommendations |
className | string | undefined | Custom CSS class name |
style | React.CSSProperties | undefined | Inline styles object |
maxItems | number | undefined | Maximum number of recommendations to display |
showPricing | boolean | true | Whether to show pricing information |
showFeatures | boolean | true | Whether to show features list |
showRatings | boolean | true | Whether to show trust scores |
showDescription | boolean | true | Whether to show product descriptions |
compact | boolean | false | Use compact mode for smaller displays |
theme | 'light' | 'dark' | 'auto' | 'auto' | Color theme |
Recommendation Object
The component expects recommendation objects with this structure:Event Handling
Click Events
Hover Events
Customization Examples
Custom Styling
Custom Styling
Responsive Configuration
Responsive Configuration
Conditional Features
Conditional Features
Advanced Usage
Loading States
Error Handling
Performance Optimization
Accessibility
The AdMeshLayout component includes built-in accessibility features:- Keyboard Navigation: Full keyboard support with tab navigation
- Screen Reader Support: Proper ARIA labels and descriptions
- Focus Management: Clear focus indicators and logical tab order
- Color Contrast: Meets WCAG 2.1 AA standards
- Responsive Design: Works with screen readers on all devices
Custom Accessibility
Browser Support
The AdMeshLayout component supports:- Chrome: 70+
- Firefox: 65+
- Safari: 12+
- Edge: 79+
- Mobile Safari: 12+
- Chrome Mobile: 70+