Dojo's TitlePane
component can be used to display content inside a window with a titlebar. When the titlebar is clicked, the content collapses. This component provides default styling for the titlebar, and content area, and will respond to different screen sizes responsively.
- Content can be prevented from collapsing
TitlePane
supports standard keyboard navigation for toggling the content open or closed.
TitleBar Events:
- Space bar: toggles the pane content of a closeable
TitlePane
- The titlebar has a role of heading and accepts a
headingLevel
property to set the correct heading level - The accordion panel has
aria-labelledby
set to the titlebar - The accordion opens on Enter and Space
aria-expanded
is set totrue
orfalse
on the toggle button depending onproperties.open
aria-controls
on the toggle button points to the accordion content
The following CSS classes are used to style the TitlePane
widget and should be provided by custom themes:
closeable
: Applied to a closeable titlebarcontent
: Applied to content of the paneroot
: Applied to the top-level wrapper nodetitle
: Applied to the titlebar
Basic Example
import TitlePane from '@dojo/widgets/title-pane';
import { w } from '@dojo/framework/widget-core/d';
w(Titlepane, {
title: 'My Pane',
open: this.state.open,
onRequestOpen: () => this.setState({ open: true }),
onRequestClose: () => this.setState({ open: false })
}, [ 'My content...' ])
TitlePane that can't be closed Basic Example
import TitlePane from '@dojo/widgets/title-pane';
import { w } from '@dojo/framework/widget-core/d';
w(Titlepane, {
title: 'My Pane',
open: true,
closeable: false
}, [ 'My content...' ])