--- name: Toolbar Header menu: Views route: examples/toolbarHeader --- import { useState } from 'react'; import { Playground } from 'docz'; import classnames from 'classnames'; import { NavBar, Typography, Svg, Icon, IconButton } from '@ohif/ui'; # Toolbar Header This example shows you how you can build a Toolbar using the available components. ## Basic usage {() => { const [activeTool, setActiveTool] = useState('Zoom'); const [showTooltip, setShowTooltip] = useState(null); const tools = [ { id: 'Zoom', label: 'Zoom', icon: 'tool-zoom', type: null, commandName: 'setToolActive', commandOptions: { toolName: 'Zoom' }, }, { id: 'Wwwc', label: 'Levels', icon: 'tool-window-level', type: null, commandName: 'setToolActive', commandOptions: { toolName: 'Wwwc' }, }, { id: 'Pan', label: 'Pan', icon: 'tool-move', type: null, commandName: 'setToolActive', commandOptions: { toolName: 'Pan' }, }, { id: 'Capture', label: 'Capture', icon: 'tool-capture', type: null, commandName: 'setToolActive', commandOptions: { toolName: 'Capture' }, }, { id: 'Layout', label: 'Layout', icon: 'tool-layout', type: null, commandName: 'setToolActive', commandOptions: { toolName: 'Layout' }, }, ]; const renderToolbar = () => { return tools.map((tool, i) => { const isActive = activeTool === tool.id; const shouldShowTooltip = showTooltip === tool.id; return (
{ setActiveTool(tool.id); }} onMouseOver={() => setShowTooltip(tool.id)} onMouseOut={() => setShowTooltip(null)} key={tool.id} > {shouldShowTooltip && (
{tool.label}
)}
); }); }; return (
alert('Navigate to previous page')} />
{renderToolbar()} { alert('Open menu'); }} >
FOR INVESTIGATIONAL USE ONLY {}} >
); }}
## Properties