# Module: Layout Template - [Module: Layout Template](#module-layout-template) - [Overview](#overview) - [Overview Video](#overview-video) ## Overview `LayoutTemplates` are a new concept in v3 that modes use to control the layout of a route. A layout template is a React component that is given a set of managers that define apis to access toolbar state, commands, and hotkeys, as well as props defined by the layout template. For instance the default LayoutTemplate takes in leftPanels, rightPanels and viewports as props, which it uses to build its view. In addition, `layout template` has complete control over the structure of the application. You could have tools down the left side, or a strict guided workflow with tools set programmatically, the choice is yours for your use case. ```jsx const getLayoutTemplateModule = (/* ... */) => [ { id: 'exampleLayout', name: 'exampleLayout', component: ExampleLayoutComponent, }, ]; ``` The `props` that are passed to `layoutTemplate` are managers and service, along with the defined mode left/right panels, mode's defined viewports and OHIF `ViewportGridComp`. LayoutTemplate leverages extensionManager to grab typed extension module entries: `*.getModuleEntry(id)` A simplified code for `Default extention`'s layout template is: ```jsx // extensions/default/src/ViewerLayout/index.jsx import React from 'react' import { SidePanel } from '@ohif/ui' function Toolbar({ servicesManager }) { const { ToolBarService } = servicesManager.services return ( <> // ToolBarService.getButtonSection('primary') to get toolbarButtons {toolbarButtons.map((toolDef, index) => { const { id, Component, componentProps } = toolDef return ( ToolBarService.recordInteraction(args)} /> ) })} ) } function ViewerLayout({ // From Extension Module Params extensionManager, servicesManager, hotkeysManager, commandsManager, // From Modes leftPanels, rightPanels, viewports, ViewportGridComp, }) { const getPanelData = (id) => { const entry = extensionManager.getModuleEntry(id) const content = entry.component return { iconName: entry.iconName, iconLabel: entry.iconLabel, label: entry.label, name: entry.name, content, } } const getViewportComponentData = (viewportComponent) => { const entry = extensionManager.getModuleEntry(viewportComponent.namespace) return { component: entry.component, displaySetsToDisplay: viewportComponent.displaySetsToDisplay, } } const leftPanelComponents = leftPanels.map(getPanelData) const rightPanelComponents = rightPanels.map(getPanelData) const viewportComponents = viewports.map(getViewportComponentData) return (
{/* LEFT SIDEPANELS */} {/* TOOLBAR + GRID */} {/* Rigth SIDEPANELS */}
) } ``` ## Overview Video