ExpandableItem
ExpandableItem creates expandable/collapsible section, similar to the HTML details disclosure element. When the user clicks on the summary the content expands or collapses.
Key features:
- Progressive disclosure: Show/hide content on demand to reduce visual clutter
- Flexible summary: Use text or rich components for the summary trigger
- Keyboard accessible: Full keyboard navigation support with Enter/Space keys
- Customizable icons: Choose your own expand/collapse icons or use a switch
Behaviors
This component supports the following behaviors:
| Behavior | Properties |
|---|---|
| Animation | animation, animationOptions |
| Bookmark | bookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc |
| Component Label | label, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly |
| Publish/Subscribe | subscribeToTopic |
| Tooltip | tooltip, tooltipMarkdown, tooltipOptions |
| Styling Variant | variant |
Properties
contentWidth
default: "100%"
Sets the width of the expanded content area. Defaults to 100% to fill the parent container.
Controls the width of the expanded content area. Defaults to 100% to fill the parent container.
<App>
<VStack gap="space-4">
<ExpandableItem
summary="Default content width (100%)"
initiallyExpanded="true">
<Stack backgroundColor="lightblue" padding="space-3">
<Text>Content fills the full width</Text>
</Stack>
</ExpandableItem>
<ExpandableItem
summary="Custom content width (50%)"
contentWidth="50%"
initiallyExpanded="true">
<Stack backgroundColor="lightgreen" padding="space-3">
<Text>Content is 50% width</Text>
</Stack>
</ExpandableItem>
</VStack>
</App><App>
<VStack gap="space-4">
<ExpandableItem
summary="Default content width (100%)"
initiallyExpanded="true">
<Stack backgroundColor="lightblue" padding="space-3">
<Text>Content fills the full width</Text>
</Stack>
</ExpandableItem>
<ExpandableItem
summary="Custom content width (50%)"
contentWidth="50%"
initiallyExpanded="true">
<Stack backgroundColor="lightgreen" padding="space-3">
<Text>Content is 50% width</Text>
</Stack>
</ExpandableItem>
</VStack>
</App>enabled
default: true
When true, the expandable item can be opened and closed. When false, it cannot be toggled.
fullWidthSummary
default: false
When true, the summary section takes the full width of the parent container. When combined with iconPosition='end', the icon is aligned to the far edge.
When true, the summary section takes the full width of the parent container, with the icon aligned to the far edge.
<App>
<VStack gap="space-4" width="100%">
<ExpandableItem
summary="Default summary (inline width)"
initiallyExpanded="true">
<Text>The summary only takes up the space it needs.</Text>
</ExpandableItem>
<ExpandableItem
summary="Full width summary"
fullWidthSummary="true"
initiallyExpanded="true">
<Text>The summary spans the full width of the parent container.</Text>
</ExpandableItem>
</VStack>
</App><App>
<VStack gap="space-4" width="100%">
<ExpandableItem
summary="Default summary (inline width)"
initiallyExpanded="true">
<Text>The summary only takes up the space it needs.</Text>
</ExpandableItem>
<ExpandableItem
summary="Full width summary"
fullWidthSummary="true"
initiallyExpanded="true">
<Text>The summary spans the full width of the parent container.</Text>
</ExpandableItem>
</VStack>
</App>iconCollapsed
default: "chevronright"
The icon to display when the item is collapsed.
iconExpanded
default: "chevrondown"
The icon to display when the item is expanded.
iconPosition
default: "end"
Determines the position of the icon (start or end).
Available values:
| Value | Description |
|---|---|
start | The icon will appear at the start (left side when the left-to-right direction is set) |
end | The icon will appear at the end (right side when the left-to-right direction is set) (default) |
initiallyExpanded
default: false
Determines if the component is initially expanded when rendered.
summary
The summary content that is always visible and acts as the trigger.
The summary property accepts either a simple text string or a component definition for rich content.
<App>
<VStack gap="space-4">
<ExpandableItem summary="Simple text summary" initiallyExpanded="true">
<Text>This expandable item uses a simple text string for its summary.</Text>
</ExpandableItem>
<ExpandableItem initiallyExpanded="false">
<property name="summary">
<CHStack gap="space-2">
<Icon name="apps" />
<Text fontWeight="600">Custom Summary with Icon</Text>
<Badge label="New" variant="success" />
</CHStack>
</property>
<Text>
This expandable item uses a rich component
definition with icons and badges in the summary.
</Text>
</ExpandableItem>
</VStack>
</App><App>
<VStack gap="space-4">
<ExpandableItem summary="Simple text summary" initiallyExpanded="true">
<Text>This expandable item uses a simple text string for its summary.</Text>
</ExpandableItem>
<ExpandableItem initiallyExpanded="false">
<property name="summary">
<CHStack gap="space-2">
<Icon name="apps" />
<Text fontWeight="600">Custom Summary with Icon</Text>
<Badge label="New" variant="success" />
</CHStack>
</property>
<Text>
This expandable item uses a rich component
definition with icons and badges in the summary.
</Text>
</ExpandableItem>
</VStack>
</App>withSwitch
default: false
When true, a switch is used instead of an icon to toggle the expanded state.
Events
expandedChange
This event fires when the expandable item is expanded or collapsed. It provides a boolean value indicating the new state.
Signature: expandedChange(isExpanded: boolean): void
isExpanded: A boolean indicating whether the item is now expanded (true) or collapsed (false).
Exposed Methods
collapse
This method collapses the item.
Signature: collapse(): void
expand
This method expands the item.
Signature: expand(): void
isExpanded
This method returns a boolean indicating whether the item is currently expanded.
Signature: isExpanded(): boolean
toggle
This method toggles the item's expanded state.
Signature: toggle(): void
Parts
The component has some parts that can be styled through layout properties and theme variables separately:
content: The content section that is expanded or collapsed.summary: The summary section that is always visible and acts as the trigger.
Styling
Theme Variables
| Variable | Default Value (Light) | Default Value (Dark) |
|---|---|---|
| animation-content-ExpandableItem | ease-out | ease-out |
| animationDuration-content-ExpandableItem | 0.2s | 0.2s |
| backgroundColor-content-ExpandableItem | none | none |
| backgroundColor-ExpandableItem | transparent | transparent |
| backgroundColor-ExpandableItem--active | none | none |
| backgroundColor-ExpandableItem--hover | none | none |
| backgroundColor-summary-ExpandableItem | none | none |
| backgroundColor-summary-ExpandableItem--active | $color-secondary-100 | $color-secondary-100 |
| backgroundColor-summary-ExpandableItem--hover | $color-secondary-100 | $color-secondary-100 |
| border-content-ExpandableItem | none | none |
| border-ExpandableItem | none | none |
| borderBottom-content-ExpandableItem | none | none |
| borderBottom-ExpandableItem | none | none |
| borderBottomColor-content-ExpandableItem | none | none |
| borderBottomColor-ExpandableItem | none | none |
| borderBottomStyle-content-ExpandableItem | none | none |
| borderBottomStyle-ExpandableItem | none | none |
| borderBottomWidth-content-ExpandableItem | none | none |
| borderBottomWidth-ExpandableItem | 1px | 1px |
| borderColor-content-ExpandableItem | none | none |
| borderColor-ExpandableItem | $borderColor | $borderColor |
| borderEndEndRadius-content-ExpandableItem | none | none |
| borderEndEndRadius-ExpandableItem | none | none |
| borderEndStartRadius-content-ExpandableItem | none | none |
| borderEndStartRadius-ExpandableItem | none | none |
| borderHorizontal-content-ExpandableItem | none | none |
| borderHorizontal-ExpandableItem | none | none |
| borderHorizontalColor-content-ExpandableItem | none | none |
| borderHorizontalColor-ExpandableItem | none | none |
| borderHorizontalStyle-content-ExpandableItem | none | none |
| borderHorizontalStyle-ExpandableItem | none | none |
| borderHorizontalWidth-content-ExpandableItem | none | none |
| borderHorizontalWidth-ExpandableItem | none | none |
| borderLeft-content-ExpandableItem | none | none |
| borderLeft-ExpandableItem | none | none |
| borderLeftColor-content-ExpandableItem | none | none |
| borderLeftColor-ExpandableItem | none | none |
| borderLeftStyle-content-ExpandableItem | none | none |
| borderLeftStyle-ExpandableItem | none | none |
| borderLeftWidth-content-ExpandableItem | none | none |
| borderLeftWidth-ExpandableItem | none | none |
| borderRadius-ExpandableItem | 0 | 0 |
| borderRadius-summary-ExpandableItem | $borderRadius | $borderRadius |
| borderRight-content-ExpandableItem | none | none |
| borderRight-ExpandableItem | none | none |
| borderRightColor-content-ExpandableItem | none | none |
| borderRightColor-ExpandableItem | none | none |
| borderRightStyle-content-ExpandableItem | none | none |
| borderRightStyle-ExpandableItem | none | none |
| borderRightWidth-content-ExpandableItem | none | none |
| borderRightWidth-ExpandableItem | none | none |
| borderStartEndRadius-content-ExpandableItem | none | none |
| borderStartEndRadius-ExpandableItem | none | none |
| borderStartStartRadius-content-ExpandableItem | none | none |
| borderStartStartRadius-ExpandableItem | none | none |
| borderStyle-content-ExpandableItem | none | none |
| borderStyle-ExpandableItem | solid | solid |
| borderTop-content-ExpandableItem | none | none |
| borderTop-ExpandableItem | none | none |
| borderTopColor-content-ExpandableItem | none | none |
| borderTopColor-ExpandableItem | none | none |
| borderTopStyle-content-ExpandableItem | none | none |
| borderTopStyle-ExpandableItem | none | none |
| borderTopWidth-content-ExpandableItem | none | none |
| borderTopWidth-ExpandableItem | none | none |
| borderVertical-content-ExpandableItem | none | none |
| borderVertical-ExpandableItem | none | none |
| borderVerticalColor-content-ExpandableItem | none | none |
| borderVerticalColor-ExpandableItem | none | none |
| borderVerticalStyle-content-ExpandableItem | none | none |
| borderVerticalStyle-ExpandableItem | none | none |
| borderVerticalWidth-content-ExpandableItem | none | none |
| borderVerticalWidth-ExpandableItem | none | none |
| borderWidth-content-ExpandableItem | none | none |
| borderWidth-ExpandableItem | 0 | 0 |
| color-ExpandableItem | $textColor-primary | $textColor-primary |
| color-ExpandableItem--disabled | $textColor--disabled | $textColor--disabled |
| direction-content-ExpandableItem | none | none |
| direction-summary-ExpandableItem | none | none |
| fontFamily-content-ExpandableItem | none | none |
| fontFamily-ExpandableItem | $fontFamily | $fontFamily |
| fontFamily-summary-ExpandableItem | none | none |
| fontSize-content-ExpandableItem | none | none |
| fontSize-ExpandableItem | none | none |
| fontSize-summary-ExpandableItem | none | none |
| fontStretch-content-ExpandableItem | none | none |
| fontStretch-summary-ExpandableItem | none | none |
| fontStyle-content-ExpandableItem | none | none |
| fontStyle-summary-ExpandableItem | none | none |
| fontVariant-content-ExpandableItem | none | none |
| fontVariant-summary-ExpandableItem | none | none |
| fontWeight-content-ExpandableItem | none | none |
| fontWeight-ExpandableItem | none | none |
| fontWeight-summary-ExpandableItem | none | none |
| gap-ExpandableItem | $space-2 | $space-2 |
| letterSpacing-content-ExpandableItem | none | none |
| letterSpacing-summary-ExpandableItem | none | none |
| lineBreak-content-ExpandableItem | none | none |
| lineBreak-summary-ExpandableItem | none | none |
| lineHeight-content-ExpandableItem | none | none |
| lineHeight-summary-ExpandableItem | none | none |
| padding-content-ExpandableItem | none | none |
| padding-ExpandableItem | none | none |
| padding-summary-ExpandableItem | $space-2 $space-4 | $space-2 $space-4 |
| paddingBottom-content-ExpandableItem | none | none |
| paddingBottom-ExpandableItem | $space-0 | $space-0 |
| paddingBottom-summary-ExpandableItem | none | none |
| paddingHorizontal-content-ExpandableItem | none | none |
| paddingHorizontal-ExpandableItem | none | none |
| paddingHorizontal-summary-ExpandableItem | none | none |
| paddingLeft-content-ExpandableItem | $space-3 | $space-3 |
| paddingLeft-ExpandableItem | $space-0 | $space-0 |
| paddingLeft-summary-ExpandableItem | none | none |
| paddingRight-content-ExpandableItem | $space-3 | $space-3 |
| paddingRight-ExpandableItem | $space-0 | $space-0 |
| paddingRight-summary-ExpandableItem | none | none |
| paddingTop-content-ExpandableItem | none | none |
| paddingTop-ExpandableItem | $space-0 | $space-0 |
| paddingTop-summary-ExpandableItem | none | none |
| paddingVertical-content-ExpandableItem | $space-2 | $space-2 |
| paddingVertical-ExpandableItem | none | none |
| paddingVertical-summary-ExpandableItem | none | none |
| textAlign-content-ExpandableItem | none | none |
| textAlign-summary-ExpandableItem | none | none |
| textAlignLast-content-ExpandableItem | none | none |
| textAlignLast-summary-ExpandableItem | none | none |
| textColor-content-ExpandableItem | none | none |
| textColor-summary-ExpandableItem | none | none |
| textDecorationColor-content-ExpandableItem | none | none |
| textDecorationColor-summary-ExpandableItem | none | none |
| textDecorationLine-content-ExpandableItem | none | none |
| textDecorationLine-summary-ExpandableItem | none | none |
| textDecorationStyle-content-ExpandableItem | none | none |
| textDecorationStyle-summary-ExpandableItem | none | none |
| textDecorationThickness-content-ExpandableItem | none | none |
| textDecorationThickness-summary-ExpandableItem | none | none |
| textIndent-content-ExpandableItem | none | none |
| textIndent-summary-ExpandableItem | none | none |
| textShadow-content-ExpandableItem | none | none |
| textShadow-summary-ExpandableItem | none | none |
| textTransform-content-ExpandableItem | none | none |
| textTransform-summary-ExpandableItem | none | none |
| textUnderlineOffset-content-ExpandableItem | none | none |
| textUnderlineOffset-summary-ExpandableItem | none | none |
| transition-summary-ExpandableItem | color 0.2s, background 0.2s | color 0.2s, background 0.2s |
| wordBreak-content-ExpandableItem | none | none |
| wordBreak-summary-ExpandableItem | none | none |
| wordSpacing-content-ExpandableItem | none | none |
| wordSpacing-summary-ExpandableItem | none | none |
| wordWrap-content-ExpandableItem | none | none |
| wordWrap-summary-ExpandableItem | none | none |
| writingMode-content-ExpandableItem | none | none |
| writingMode-summary-ExpandableItem | none | none |