Room Visualizer

A responsive, flexible room visualization component that allows users to select room types and styles, generate room images, and view furniture product recommendations.

Basic Usage

Simply place the <room-visualizer> element anywhere in your application. The component will adapt to the parent container's width.

<room-visualizer></room-visualizer>

Demo

Container Width

The component will stretch to fill the width of its parent container. You can control the width by setting the width of the parent element:

<div style="width: 800px;">
  <room-visualizer></room-visualizer>
</div>

Usage Options

<room-visualizer 
  lang="en" 
  currency="USD">
</room-visualizer>
const visualizer = document.querySelector('room-visualizer');

// Listen for room selection
visualizer.addEventListener('roomSelected', event => {
  console.log('Room selected:', event.detail);
});

// Listen for style selection
visualizer.addEventListener('styleSelected', event => {
  console.log('Style selected:', event.detail);
});

// Listen for product clicks
visualizer.addEventListener('productClicked', event => {
  console.log('Product clicked:', event.detail);
});
// Generate a room visualization
const requestData = {
  room: 'living-room',
  styles: ['modern', 'minimal'],
  aspect_ratio: '16:9'
};

fetch('https://platform-api.youzu.ai/api/v1/generation', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'x-client-id': 'YOUR_CLIENT_ID',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => {
  console.log('Generation completed:', data);
  // Display the generated image using data.image_url
})
.catch(error => {
  console.error('Error:', error);
});
import requests
import json

# Generate a room visualization
request_data = {
    'room': 'living-room',
    'styles': ['modern', 'minimal'],
    'aspect_ratio': '16:9'
}

headers = {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'x-client-id': 'YOUR_CLIENT_ID',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://platform-api.youzu.ai/api/v1/generation',
    headers=headers,
    data=json.dumps(request_data)
)

if response.status_code == 200:
    generation = response.json()
    print('Generation completed:', generation)
    # Display the generated image using generation['image_url']
else:
    print('Error:', response.status_code, response.text)
curl -X POST https://platform-api.youzu.ai/api/v1/generation \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-client-id: YOUR_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "room": "living-room",
    "styles": ["modern", "minimal"],
    "aspect_ratio": "16:9"
  }'

Responsive Behavior

The component handles different screen sizes with these breakpoints:

  • Mobile view (< 480px): Single-column grid layouts
  • Tablet view (< 768px): Adjusted layout with stacked elements
  • Desktop view (≥ 768px): Two-column layouts for product recommendations

Props

Property Attribute Type Default
currency currency string undefined
customProperties custom-properties ApiV1LensPostRequestCustomProperties undefined
features features FeatureFlags undefined
generationId generation-id string undefined
lang lang string undefined
noIntro no-intro boolean undefined

Events

Event Description Type
generationComplete CustomEvent<Generation>
productAddedToBasket CustomEvent<ApiV1LensPost200ResponseInner>
productClicked CustomEvent<ApiV1LensPost200ResponseInner>
profileClicked CustomEvent<void>
roomSelected CustomEvent<{ roomId: string; roomName: string; }>
styleSelected CustomEvent<{ styleId: string; styleName: string; }>