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:

BehaviorProperties
Animationanimation, animationOptions
Bookmarkbookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc
Component Labellabel, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly
Publish/SubscribesubscribeToTopic
Tooltiptooltip, tooltipMarkdown, tooltipOptions
Styling Variantvariant

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>
Example: contentWidth
<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>
Example: fullWidthSummary
<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:

ValueDescription
startThe icon will appear at the start (left side when the left-to-right direction is set)
endThe 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>
Example: summary
<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

VariableDefault Value (Light)Default Value (Dark)
animation-content-ExpandableItemease-outease-out
animationDuration-content-ExpandableItem0.2s0.2s
backgroundColor-content-ExpandableItemnonenone
backgroundColor-ExpandableItemtransparenttransparent
backgroundColor-ExpandableItem--activenonenone
backgroundColor-ExpandableItem--hovernonenone
backgroundColor-summary-ExpandableItemnonenone
backgroundColor-summary-ExpandableItem--active$color-secondary-100$color-secondary-100
backgroundColor-summary-ExpandableItem--hover$color-secondary-100$color-secondary-100
border-content-ExpandableItemnonenone
border-ExpandableItemnonenone
borderBottom-content-ExpandableItemnonenone
borderBottom-ExpandableItemnonenone
borderBottomColor-content-ExpandableItemnonenone
borderBottomColor-ExpandableItemnonenone
borderBottomStyle-content-ExpandableItemnonenone
borderBottomStyle-ExpandableItemnonenone
borderBottomWidth-content-ExpandableItemnonenone
borderBottomWidth-ExpandableItem1px1px
borderColor-content-ExpandableItemnonenone
borderColor-ExpandableItem$borderColor$borderColor
borderEndEndRadius-content-ExpandableItemnonenone
borderEndEndRadius-ExpandableItemnonenone
borderEndStartRadius-content-ExpandableItemnonenone
borderEndStartRadius-ExpandableItemnonenone
borderHorizontal-content-ExpandableItemnonenone
borderHorizontal-ExpandableItemnonenone
borderHorizontalColor-content-ExpandableItemnonenone
borderHorizontalColor-ExpandableItemnonenone
borderHorizontalStyle-content-ExpandableItemnonenone
borderHorizontalStyle-ExpandableItemnonenone
borderHorizontalWidth-content-ExpandableItemnonenone
borderHorizontalWidth-ExpandableItemnonenone
borderLeft-content-ExpandableItemnonenone
borderLeft-ExpandableItemnonenone
borderLeftColor-content-ExpandableItemnonenone
borderLeftColor-ExpandableItemnonenone
borderLeftStyle-content-ExpandableItemnonenone
borderLeftStyle-ExpandableItemnonenone
borderLeftWidth-content-ExpandableItemnonenone
borderLeftWidth-ExpandableItemnonenone
borderRadius-ExpandableItem00
borderRadius-summary-ExpandableItem$borderRadius$borderRadius
borderRight-content-ExpandableItemnonenone
borderRight-ExpandableItemnonenone
borderRightColor-content-ExpandableItemnonenone
borderRightColor-ExpandableItemnonenone
borderRightStyle-content-ExpandableItemnonenone
borderRightStyle-ExpandableItemnonenone
borderRightWidth-content-ExpandableItemnonenone
borderRightWidth-ExpandableItemnonenone
borderStartEndRadius-content-ExpandableItemnonenone
borderStartEndRadius-ExpandableItemnonenone
borderStartStartRadius-content-ExpandableItemnonenone
borderStartStartRadius-ExpandableItemnonenone
borderStyle-content-ExpandableItemnonenone
borderStyle-ExpandableItemsolidsolid
borderTop-content-ExpandableItemnonenone
borderTop-ExpandableItemnonenone
borderTopColor-content-ExpandableItemnonenone
borderTopColor-ExpandableItemnonenone
borderTopStyle-content-ExpandableItemnonenone
borderTopStyle-ExpandableItemnonenone
borderTopWidth-content-ExpandableItemnonenone
borderTopWidth-ExpandableItemnonenone
borderVertical-content-ExpandableItemnonenone
borderVertical-ExpandableItemnonenone
borderVerticalColor-content-ExpandableItemnonenone
borderVerticalColor-ExpandableItemnonenone
borderVerticalStyle-content-ExpandableItemnonenone
borderVerticalStyle-ExpandableItemnonenone
borderVerticalWidth-content-ExpandableItemnonenone
borderVerticalWidth-ExpandableItemnonenone
borderWidth-content-ExpandableItemnonenone
borderWidth-ExpandableItem00
color-ExpandableItem$textColor-primary$textColor-primary
color-ExpandableItem--disabled$textColor--disabled$textColor--disabled
direction-content-ExpandableItemnonenone
direction-summary-ExpandableItemnonenone
fontFamily-content-ExpandableItemnonenone
fontFamily-ExpandableItem$fontFamily$fontFamily
fontFamily-summary-ExpandableItemnonenone
fontSize-content-ExpandableItemnonenone
fontSize-ExpandableItemnonenone
fontSize-summary-ExpandableItemnonenone
fontStretch-content-ExpandableItemnonenone
fontStretch-summary-ExpandableItemnonenone
fontStyle-content-ExpandableItemnonenone
fontStyle-summary-ExpandableItemnonenone
fontVariant-content-ExpandableItemnonenone
fontVariant-summary-ExpandableItemnonenone
fontWeight-content-ExpandableItemnonenone
fontWeight-ExpandableItemnonenone
fontWeight-summary-ExpandableItemnonenone
gap-ExpandableItem$space-2$space-2
letterSpacing-content-ExpandableItemnonenone
letterSpacing-summary-ExpandableItemnonenone
lineBreak-content-ExpandableItemnonenone
lineBreak-summary-ExpandableItemnonenone
lineHeight-content-ExpandableItemnonenone
lineHeight-summary-ExpandableItemnonenone
padding-content-ExpandableItemnonenone
padding-ExpandableItemnonenone
padding-summary-ExpandableItem$space-2 $space-4$space-2 $space-4
paddingBottom-content-ExpandableItemnonenone
paddingBottom-ExpandableItem$space-0$space-0
paddingBottom-summary-ExpandableItemnonenone
paddingHorizontal-content-ExpandableItemnonenone
paddingHorizontal-ExpandableItemnonenone
paddingHorizontal-summary-ExpandableItemnonenone
paddingLeft-content-ExpandableItem$space-3$space-3
paddingLeft-ExpandableItem$space-0$space-0
paddingLeft-summary-ExpandableItemnonenone
paddingRight-content-ExpandableItem$space-3$space-3
paddingRight-ExpandableItem$space-0$space-0
paddingRight-summary-ExpandableItemnonenone
paddingTop-content-ExpandableItemnonenone
paddingTop-ExpandableItem$space-0$space-0
paddingTop-summary-ExpandableItemnonenone
paddingVertical-content-ExpandableItem$space-2$space-2
paddingVertical-ExpandableItemnonenone
paddingVertical-summary-ExpandableItemnonenone
textAlign-content-ExpandableItemnonenone
textAlign-summary-ExpandableItemnonenone
textAlignLast-content-ExpandableItemnonenone
textAlignLast-summary-ExpandableItemnonenone
textColor-content-ExpandableItemnonenone
textColor-summary-ExpandableItemnonenone
textDecorationColor-content-ExpandableItemnonenone
textDecorationColor-summary-ExpandableItemnonenone
textDecorationLine-content-ExpandableItemnonenone
textDecorationLine-summary-ExpandableItemnonenone
textDecorationStyle-content-ExpandableItemnonenone
textDecorationStyle-summary-ExpandableItemnonenone
textDecorationThickness-content-ExpandableItemnonenone
textDecorationThickness-summary-ExpandableItemnonenone
textIndent-content-ExpandableItemnonenone
textIndent-summary-ExpandableItemnonenone
textShadow-content-ExpandableItemnonenone
textShadow-summary-ExpandableItemnonenone
textTransform-content-ExpandableItemnonenone
textTransform-summary-ExpandableItemnonenone
textUnderlineOffset-content-ExpandableItemnonenone
textUnderlineOffset-summary-ExpandableItemnonenone
transition-summary-ExpandableItemcolor 0.2s, background 0.2scolor 0.2s, background 0.2s
wordBreak-content-ExpandableItemnonenone
wordBreak-summary-ExpandableItemnonenone
wordSpacing-content-ExpandableItemnonenone
wordSpacing-summary-ExpandableItemnonenone
wordWrap-content-ExpandableItemnonenone
wordWrap-summary-ExpandableItemnonenone
writingMode-content-ExpandableItemnonenone
writingMode-summary-ExpandableItemnonenone