# Expandable panel

A compact project summary expands smoothly into useful detail.

## Usage

Use for a compact summary that has optional details. Keep the summary sufficient to identify the item. The panel manages its own open state.

Save the JSX and CSS Module in the same folder in a React project with CSS Modules support. Controlled components need parent state and change handlers.

## JSX

```jsx
"use client";
import styles from "./ExpandablePanel.module.css";
import { useState, useId } from "react";
export default function ExpandablePanel({
  title = "Website refresh",
  summary = "A little progress, every day.",
  children = "Review the direction, align the details, and prepare the next iteration for your team.",
}) {
  const [open, setOpen] = useState(false);
  const id = useId();
  return (
    <div className={styles.root}>
      <button
        type="button"
        aria-expanded={open}
        aria-controls={id}
        onClick={() => setOpen(!open)}
      >
        <span className={styles.icon} aria-hidden="true">
          ▤
        </span>
        <span>
          <strong>{title}</strong>
          <small>{summary}</small>
        </span>
        <span className={styles.plus} aria-hidden="true">
          {open ? "−" : "+"}
        </span>
      </button>
      <div id={id} className={styles.expand} data-open={open} inert={!open}>
        <div>
          <div className={styles.body}>
            {children}
            <span className={styles.status}>Ready for review</span>
          </div>
        </div>
      </div>
    </div>
  );
}

```

## CSS

```css
.root {
  width: 320px;
  background: var(--tdp-surface, #fffdfa);
  border: 1px solid var(--tdp-border, #d9d1c9);
  border-radius: var(--tdp-radius, 8px);
  overflow: hidden;
  box-shadow: 0 8px 25px #4433230a;
}
.root > button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  min-height: 72px;
}
.icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 44px;
  background: #e6ddef;
  border-radius: 8px;
  font-size: 25px;
}
.root strong {
  font-size: 14px;
  font-weight: 600;
  display: block;
}
.root small {
  font-size: 11px;
  color: var(--tdp-muted, #6b625b);
  display: block;
  margin-top: 5px;
}
.plus {
  font-size: 20px;
  margin-left: auto;
}
.expand {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.3s;
}
.expand[data-open="true"] {
  grid-template-rows: 1fr;
  opacity: 1;
}
.expand > div {
  overflow: hidden;
}
.body {
  border-top: 1px solid var(--tdp-border, #d9d1c9);
  padding: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--tdp-muted, #6b625b);
}
.status {
  display: table;
  margin-top: 18px;
  padding: 5px 9px;
  border-radius: 5px;
  background: #e7efdf;
  color: #3b5430;
  font-size: 11px;
}
.root {
  font-family: var(--tdp-font, "DM Sans", system-ui, sans-serif);
  color: var(--tdp-text, #302e2b);
  max-width: 100%;
  box-sizing: border-box;
}
.root * {
  box-sizing: border-box;
}
.root :is(button, input, a):focus-visible,
.root:focus-visible {
  outline: 3px solid var(--tdp-focus, #7851a9);
  outline-offset: 4px;
}
.root button {
  font: inherit;
  cursor: pointer;
}
.root button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.root button,
.root a {
  touch-action: manipulation;
}
@media (prefers-reduced-motion: reduce) {
  .root,
  .root *,
  .root::before,
  .root::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    translate: none !important;
    rotate: none !important;
    scale: none !important;
    scroll-behavior: auto !important;
  }
}

```

## Props

- title (string): Summary heading.
- summary (string): Short supporting text.
- children (ReactNode): Expanded content.

## Accessibility

The trigger exposes aria-expanded and aria-controls. The closed content is inert so nested controls cannot receive focus. The reveal uses a reduced-motion-aware grid transition.

Check accessibility again after customizing the component.

[Browse all components](/resources/components/)

Canonical: https://designproject.io/resources/components/expandable-panel/

## Keep learning

- [How to create a UI color palette, step by step](https://designproject.io/resources/guides/create-ui-color-palette/)
- [Product design glossary: 44 terms explained](https://designproject.io/resources/glossary/)
- [How to choose font pairings for a product interface](https://designproject.io/resources/guides/choose-font-pairings/)
