lara-light-indigo

Sidebar

Sidebar is a panel component displayed as an overlay.

Import via Module

import { Sidebar } from 'primereact/sidebar';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/sidebar/sidebar.min.js"></script>
 
Getting Started

Sidebar is used as a container and visibility is controlled with visible property.


<Sidebar visible={visible} onHide={() => setVisible(false)}>
    Content
</Sidebar>

<Button icon="pi pi-arrow-right" onClick={(e) => setVisible(true)}/>
 
Position

Sidebar can either be located on the left (default), right, top or bottom of the screen depending on the position property.


<Sidebar visible={visible} position="right" onHide={() => setVisible(false)}>
    Content
</Sidebar>
 
Size

Sidebar size can be changed using a fixed value or using one of the three predefined ones.


<Sidebar visible={visible} position="right" className="p-sidebar-sm" onHide={() => setVisible(false)}></Sidebar>
<Sidebar visible={visible} position="right" className="p-sidebar-md" onHide={() => setVisible(false)}></Sidebar>
<Sidebar visible={visible} position="right" className="p-sidebar-lg" onHide={() => setVisible(false)}></Sidebar>
<Sidebar visible={visible} position="right" style={{width:'30em'}} onHide={() => setVisible(false)}></Sidebar>
 
Full Screen

Full screen mode allows the sidebar to cover whole screen.


<Sidebar visible={visible} fullScreen onHide={() => setVisible(false)}}>
    Content
</Sidebar>
 
Custom toolbar

Additional content can be provided using the icons property.


<Sidebar visible={visibleCustomToolbar} onHide={() => setVisibleCustomToolbar(false)} icons={() => (
    <React.Fragment>
        <button className="p-sidebar-close p-link">
            <span className="p-sidebar-close-icon pi pi-print"/>
        </button>
        <button className="p-sidebar-close p-link">
            <span className="p-sidebar-close-icon pi pi-arrow-right"/>
        </button>
    </React.Fragment>
)}>
    <h1 style={{fontWeight:'normal'}}>Sidebar with custom icons</h1>
    <Button type="button" onClick={(e) => setVisibleCustomToolbar(false)} label="Save" className="p-button-success" style={{marginRight:'.25em'}} />
    <Button type="button" onClick={(e) => setVisibleCustomToolbar(false)} label="Cancel" className="p-button-secondary"/>
</Sidebar>
 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
styleobjectnullInline style of the component.
classNamestringnullStyle class of the component.
maskStylestringnullInline style of the mask.
maskClassNamestringnullStyle class of the mask.
visiblebooleanfalseSpecifies the visibility of the dialog.
positionstringleftSpecifies the position of the sidebar, valid values are "left" and "right".
fullScreenbooleanfalseAdds a close icon to the header to hide the dialog.
blockScrollbooleanfalseWhether to block scrolling of the document when sidebar is active.
baseZIndexnumber0Base zIndex value to use in layering.
dismissablebooleantrueWhether to dismiss sidebar on click of the mask.
showCloseIconbooleantrueWhether to display a close icon inside the panel.
ariaCloseLabelstringcloseAria label of the close icon.
iconsanynullCustom icons template for the header.
modalbooleantrueWhether to a modal layer behind the sidebar.
appendToDOM element | stringdocument.bodyDOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
closeOnEscapebooleantrueSpecifies if pressing escape key should hide the sidebar.
transitionOptionsobjectnullThe properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
Events
NameParametersDescription
onHide-Callback to invoke when the actions used to close the sidebar are triggered. Exp; close icon, mask and esc key.
onShow-Callback to invoke when sidebar gets shown.
Styling

Following is the list of structural style classes.

NameElement
p-sidebarContainer element
p-sidebar-leftContainer element of left sidebar.
p-sidebar-rightContainer element of right sidebar.
p-sidebar-topContainer element of top sidebar.
p-sidebar-bottomContainer element of bottom sidebar.
p-sidebar-fullContainer element of a full screen sidebar.
p-sidebar-activeContainer element when sidebar is visible.
p-sidebar-closeClose anchor element.
p-sidebar-smSmall sized sidebar.
p-sidebar-mdMedium sized sidebar.
p-sidebar-lgLarge sized sidebar.
p-sidebar-viewThe page view is displayed according to the sidebar position.
p-sidebar-contentA content is displayed according to the sidebar position. To use this style, a sidebar must be created inside that content using the appendTo property and this content must have position:"relative" style.
p-sidebar-maskModal layer of the sidebar.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma