🚧 Under Construction

This component documentation is currently being developed. Some features may be incomplete.

Sidebar Dialog

View in Pattern Lab

HTML Markup

<dialog id="dlgsb" class="hoo-dlg sidebar ">
    <div class="hoo-dlgheader">
        <div class="hoo-dlgheader-title">
            <h2>Dialog Header</h2>
        </div>
        <div class="hoo-dlgheader-closer">
            <button class="hoo-buttonicon" 
        
        
        ><span class="hoo-icon">
                <svg class="hoo-icon-svg icon-close" aria-hidden="true">
                    <use xlink:href="/htwoo-core/images/icons.svg#icon-close">
                    </use>
                </svg></span>
        </button>
    </div>
</div>
<div class="hoo-dlgcontent">
    <p>This dialog is a sidebar on the . That automatically scales with the content.</p>
    <p>To make the width fixed add the CSS variable<code>--hoo-dlg-width</code>
</p>
<h2>Try to resize the sidebar</h2>
<button class="hoo-button-primary" id='width-unset'><span class="hoo-button-label">Unset / reset</span>
</button>
<button class="hoo-button-primary" id='width-20vw'><span class="hoo-button-label">20% width</span>
</button>
<button class="hoo-button-primary" id='width-50vw'><span class="hoo-button-label">50% width</span>
</button>
<button class="hoo-button-primary" id='width-75vw'><span class="hoo-button-label">75% width</span>
</button>
</div>
</dialog>
<!--- ⬇️ Script below is just for demo purposes ⬇️ -->
    <script>let dlg = document.querySelector('#dlgsb');

    if (dlg !== undefined && dlg.parentElement.className === 'dlg-background') {

        dlg ? dlg.showModal() : dlg;

        const resize = (event) => {

            console.debug(event.currentTarget.id);

            let newSize = null;

            switch (event.currentTarget.id) {
                case 'width-unset':
                    break;
                case 'width-20vw':
                    newSize = '20vw';
                    break;
                case 'width-50vw':
                    newSize = '50vw';
                    break;
                case 'width-75vw':
                    newSize = '75vw';
                    break;
                default:
                    break;
            }

            console.debug(dlg, newSize);

            if (dlg && newSize) {

                console.debug(' --- Update ....')
                dlg.style.setProperty('--hoo-dlg-width', newSize);

            } else {
                if (newSize === null) {
                    dlg.style.setProperty('--hoo-dlg-width', null);
                }
            }
        }

        let resizers = document.querySelectorAll("button[id^='width']");

        console.debug(resizers);

        resizers.forEach(resizer => resizer.addEventListener('click', resize));
    }</script>

Sidebar Dialog

The Sidebar Dialog component provides a panel that slides in from either the left or right side of the screen. It’s ideal for displaying supplementary content, forms, or navigation options without navigating away from the current view.

Overview

Sidebar dialogs in HTWOO UI leverage the HTML5 <dialog> element with special positioning to create panels that appear from the side of the screen. They can be positioned on either the left or right side and can take up the full height of the viewport.

Features

  • Left or right side positioning
  • Full-height viewport display
  • Customizable width via CSS variables
  • Support for resizing through user interaction
  • Smooth animation transitions
  • Optional dialog header with title and close button
  • Dialog content area for main information
  • Optional backdrop when opened modally

Usage

The Sidebar Dialog can be implemented with the following structure:

<!-- Right Sidebar -->
<dialog id="mySidebarRight" class="hoo-dlg sidebar right">
  <!-- Dialog header -->
  <div class="hoo-dlgheader">
    <h2>Sidebar Title</h2>
    <button class="hoo-button-icon" aria-label="Close">×</button>
  </div>
  
  <!-- Dialog content -->
  <div class="hoo-dlgcontent">
    <p>Sidebar content goes here</p>
  </div>
</dialog>

<!-- Left Sidebar -->
<dialog id="mySidebarLeft" class="hoo-dlg sidebar left">
  <!-- Dialog header -->
  <div class="hoo-dlgheader">
    <h2>Sidebar Title</h2>
    <button class="hoo-button-icon" aria-label="Close">×</button>
  </div>
  
  <!-- Dialog content -->
  <div class="hoo-dlgcontent">
    <p>Sidebar content goes here</p>
  </div>
</dialog>

Opening the Dialog

Customizing Width

Sidebar dialog width can be customized using CSS variables:

<dialog class="hoo-dlg sidebar right" style="--hoo-dlg-width: 25vw">
  <!-- Dialog content -->
</dialog>

SCSS Files

Dialog Styles:

  • src/styles/03-organism/dialog/_dialog.scss

Accessibility

  • Uses the native HTML5 <dialog> element
  • Ensures focus is trapped within the dialog when open
  • ESC key closes the dialog by default
  • Proper focus management with autofocus attribute
  • ARIA attributes for screen reader compatibility