I need different widths for my LWC for lightning and classic(lightning out) as my LWC is shooting out of card width in lightning.
I am able to know whether a user is in lightning or classic using wire and apex. How can I use it to dynamically control the width of LWC?
APEX
public with sharing class ThemeTest {
@auraEnabled(cacheable=true)
public static String getUIThemeDescription() {
String theme = UserInfo.getUiThemeDisplayed();
return theme;
}
}
This is how I get the context. (I want to set the component width here)
@wire(getUITheme) theme({error,data}){
if(data==='Theme4d'){
this.isLightning=true;
}
if(error){
this.error1 = error;
}
}
HTML
<div id="setWidth" class="slds-scrollable" style="height:20rem;width:66rem">
<lightning-datatable
key-field="Id"
data={wrappers}
columns={columns}
onrowaction={navigateToRecordViewPage}
hide-checkbox-column="true">
</lightning-datatable>
</div>
</div>