Перейти к контенту

Expansion Panel (панель расширения)

Панель расширения содержит потоки создания и позволяет легко редактировать элементы.

Expansion panel это простой контейнер, который может использоваться отдельно, либо как часть более крупного компонента, такого как Card (карточка).

Note: Expansion panels are no longer documented in the Material Design guidelines, but Material-UI will continue to support them.

Простая Expansion Panel

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

Контролируемый "Аккордеон"

Используя компонент ExpansionPanel, расширив его поведение по умолчанию, можно получить "аккордеон".

Nulla facilisi. Phasellus sollicitudin nulla et quam mattis feugiat. Aliquam eget maximus est, id dignissim quam.

Donec placerat, lectus sed mattis semper, neque lectus feugiat lectus, varius pulvinar diam eros in elit. Pellentesque convallis laoreet laoreet.

Nunc vitae orci ultricies, auctor nunc in, volutpat nisl. Integer sit amet egestas eros, vitae egestas augue. Duis vel est augue.

Nunc vitae orci ultricies, auctor nunc in, volutpat nisl. Integer sit amet egestas eros, vitae egestas augue. Duis vel est augue.

Customized expansion panels

Ниже находится пример кастомизации компонента. You can learn more about this in the overrides documentation page.

Collapsible Group Item #1

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.

Additional actions

In order to put an action such as a Checkbox or a button inside of the ExpansionPanelSummary, you need to stop the propagation of the focus and click events to prevent the panel from expanding/collapsing when using the action. You should also provide an aria-label for the action, otherwise the label of the nested action will be included in the label of the parent button that controls the panel expansion.

The click event of the nested action will propagate up and expand the panel unless you explicitly stop it.

The focus event of the nested action will propagate up and also focus the expansion panel unless you explicitly stop it.

If you forget to put an aria-label on the nested action, the label of the action will also be included in the label of the parent button that controls the panel expansion.

Производительность

Содержимое ExpansionPanels монтируется по умолчанию, даже если панель не развернута. Это предопределенное поведение подразумевает рендеринг на стороне сервера и SEO. If you render expensive component trees inside your panels or simply render many panels it might be a good idea to change this default behavior by enabling the unmountOnExit in TransitionProps:

<ExpansionPanel TransitionProps={{ unmountOnExit: true }} />

Как и при любой оптимизации производительности, не стоит переоценивать её. Сначала идентифицируйте узкие места и лишь затем пытайтесь применить эти стратегии.

Подзаголовок и столбцы

Содержимое панели можно структурировать, сгруппировав его в отдельные столбцы, кроме того можно добавить подзаголовок и подсказки для пользователя.

Location

Select trip destination

Barbados
Select your destination of choice
Learn more

Доступность

(WAI-ARIA: https://www.w3.org/TR/wai-aria-practices/#accordion)

Для оптимальной доступности мы рекомендуем установить id и aria-controls на ExpansionPanelSummary. ExpansionPanel унаследует необходимые aria-labelbyby и id для области содержимого панели.