Menu

On this page

Panel

A styled container component for structured content with optional header, body, and footer sections.

npm install @vrembem/panel
Copied!
SCSS
@use "@vrembem/panel";
Copied!

Options

Panel uses design token CSS variables in a reference and fallback pattern. Variables are referenced in the component's styles but are not directly defined; instead, they are provided with sensible fallbacks.

VariableFallback
--vb-panel-background
Copied!
var(--vb-background)
Copied!
--vb-panel-foreground
Copied!
var(--vb-foreground)
Copied!
--vb-panel-border
Copied!
none
Copied!
--vb-panel-sep-border
Copied!
var(--vb-border)
Copied!
--vb-panel-border-radius
Copied!
var(--vb-border-radius)
Copied!
--vb-panel-box-shadow
Copied!
var(--vb-box-shadow-border)
Copied!
--vb-panel-padding
Copied!
1em
Copied!
--vb-panel-gap
Copied!
0.5em
Copied!
--vb-panel-transition-timing-function
Copied!
--vb-panel-transition-duration
Copied!
--vb-panel-transition-property
Copied!
outline, box-shadow, border-color
Copied!
--vb-panel-title-color
Copied!
--vb-panel-title-font-size
Copied!
var(--vb-font-size-lg)
Copied!
--vb-panel-title-font-weight
Copied!
--vb-panel-title-line-height
Copied!
inherit
Copied!
--vb-panel-caret-color
Copied!
currentcolor
Copied!

Basic usage

Panel is a highly composable container component that comes with a variety of elements. The most basic implementation being panel and a panel__body element:

Basic panel example.

HTML
<div class="panel">
  <div class="panel__body">
    ...
  </div>
</div>
Copied!

Elements

The panel component comes with a variety of elements to help fit a wide range of use cases and applications. You can mix and match these elements within the panel component as needed.

Panel example

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed libero nulla, suscipit consectetur lectus eu, rhoncus eleifend erat. Suspendisse neque dui, ornare non molestie in, rhoncus id lectus.

HTML
<div class="panel box-shadow-xl">
  <div class="panel__header">
    <h2 class="panel__title">...</h2>
    <button class="button">...</button>
  </div>
  <div class="panel__body">
    ...
  </div>
  <div class="panel__footer">
    ...
  </div>
</div>
Copied!

Use box-shadow-[key] utilities to increase the elevation of a panel. This can be useful for modal dialogs or popovers.

Available Elements

  • panel__container
    • panel__header
      • panel__title
    • panel__body
    • panel__footer

The panel__container element is an optional scrollable container that separates content scrolling from the panel's background and border styles, preventing overscroll visual issues.

Collapsable

It's also possible to create collapsable panels by using the <details> for the root .panel and <summary> for the panel__header element.

Collapsable panel

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed libero nulla, suscipit consectetur lectus eu, rhoncus eleifend erat. Suspendisse neque dui, ornare non molestie in, rhoncus id lectus.

Collapsable panel

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed libero nulla, suscipit consectetur lectus eu, rhoncus eleifend erat. Suspendisse neque dui, ornare non molestie in, rhoncus id lectus.

HTML
<details class="panel">
  <summary class="panel__header">
    <h2 class="panel__title">...</h2>
  </summary>
  <div class="panel__body">
    ...
  </div>
</details>
Copied!

Focusable

There are cases where a panel needs to be focusable. For these instances, apply tabindex="0" to the panel element itself. Focus ring styles are applied to panels for the :focus-visible state.

Focusable panel

This panel can be focused by clicking or using keyboard navigation. To see :focus-visible styles, click on this panel and press the shift key.

HTML
<div class="panel" tabindex="0">
  ...
</div>
Copied!