To switch to a compact sidebar, add data-sidenav-size="compact" to the <html> tag in your layout. You can apply this dynamically using the LayoutStoreService with setSidenavSize('compact').