Skip to main content

So what I want is to make a custom theme layout, having a sidebar which will hold all my navigation links and than the main area where each of my page will render. I want my LWR site to follow this theme. but I am having issues trying to grasp the idea of custom theme layouts, the documentations are not that concise neither was the YT videos.

 

Below is my code:

html:

<template>  <section class="theme-container">    <aside class="sidebar">      <slot></slot>    </aside>    <section class="content">      <slot name="main"></slot>    </section>  </section></template>

Javascript:

 

import { LightningElement } from "lwc";/** * @slot default * @slot main */export default class SidebarCustomTheme extends LightningElement {}

CSS:

 

.theme-container {  display: flex;  background-color: red;  min-height: 100dvh;}.sidebar {  flex: 0.5;  background-color: lightcoral;  min-height: 100dvh;}.content {  flex: 2;  background-color: lightblue;}.full-height {  min-height: 100dvh;}

 

Now when I make this my theme for a current page, the slot which is named "main" it wont let me drop any component there, and in the default slot which is in my sidebar, it is letting me. I am not sure how these named slots work, I have read the documentation and saw the video on youtube as well, they gave only high level information. Does anyone have any idea what am I doing wrong or what I am trying is possible?

 

#Salesforce Developer

1 risposta