React Native · Components
Collapsible
A single collapsible section: "Advanced settings", "Show details", "Show more" on long text.
2 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Debug mode, verbose logging and experimental features are here. Search for "experimental" with the browser's find in page (Ctrl+F): the section opens by itself.
Code
Events
- Events appear here when you interact with the preview.
With your own button
- 2 × Coffee beans
- 1 × French press
Import
Collapsible
componentA single collapsible section: "Advanced settings", "Show details", "Show more" on long text. For multiple sections use Accordion. Height is animated; instant with "reduce motion".
Examples
CollapsibleProps
interfaceProps of Collapsible.
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<ViewRef> | Ref of the underlying native element. | |
children? | ReactNode | Content that opens and closes. | |
title? | ReactNode | Text of the built-in header row. Not used if trigger is given. | |
description? | ReactNode | Small description below the title. | |
icon? | IconProp | Icon at the start of the title. | |
trigger? | ReactElement<{ onPress?: (...args: never[]) => unknown; "aria-expanded"?: boolean; }> | Your own toggle button instead of the built-in header (e.g. <Button variant="ghost">). Toggles on press; onPress and aria-expanded are added. | |
open? | boolean | Open (controlled). | |
defaultOpen? | boolean | false | Initially open (uncontrolled). |
onOpenChange? | (open: boolean) => void | When it opens or closes. | |
disabled? | boolean | Cannot be toggled. | |
collapsedHeight? | number | "Show more" mode: while closed this much of the content (pixels) is visible, ending with a fading bottom edge; the button below opens it fully. If the content is shorter, no button appears. | |
showMoreLabel? | ReactNode | the {@link UIProvider} text | Text of the "Show more" button. |
showLessLabel? | ReactNode | the {@link UIProvider} text | Text of the "Show less" button. |
effect? | EffectProp | Effect of the built-in header row ("ripple", "glow"…). Defaults to appearance.defaults.collapsible.effect. See BuiltinEffect. | |
style? | StyleProp<ViewStyle> | Container style. |