A single panel that a trigger shows and hides.
import { Collapsible } from '@oztix/roadie-components/collapsible'
A bare trigger is a text control with a trailing caret. Pad the content inside the panel, not the panel itself, so it closes all the way.
The part is .Panel, matching Base UI and Tabs.Panel. Roadie keeps .Content for popup wrappers such as Select.Content.
Render the trigger onto a Button. The trigger keeps the button's styles and adds its own caret. Here open is controlled so the label can change, and hiddenUntilFound lets find in page reach the closed text.
Tuck advanced filters behind a button. keepMounted keeps the closed panel in the page, so what someone typed survives closing it.
Put Collapsible.Text inside a Collapsible to clamp a paragraph to a few lines and end the last one with an inline "…more". The Collapsible holds the open state, so open, defaultOpen and onOpenChange go on it, as they do for a panel. It fades the end of that line into whatever surface it sits on, and shows the trigger only when the text runs past the clamp. lines sets the clamp (3 by default), moreLabel and lessLabel set the labels, and lessLabel={null} expands only.
<Collapsible><Collapsible.Trigger>Show all 12 ticket types</Collapsible.Trigger><Collapsible.Panel>…</Collapsible.Panel></Collapsible>
Do
Use Collapsible for one panel that belongs to the content around it: the rest of a list, the rest of a description, extra filters.
<Collapsible>…</Collapsible><Collapsible>…</Collapsible><Collapsible>…</Collapsible>
Don’t
Don't stack Collapsibles into a list of questions or sections. Use Accordion, which groups them and can keep one open at a time.
Do
Name what the panel holds, with a count where you have one: "Show all 12 ticket types", "Advanced filters".
Don’t
Don't hide what most people need, like the price or the date. Keep it above the trigger.
<Collapsible><Collapsible.Text lines={2}>{ticket.description}</Collapsible.Text></Collapsible>
Do
Clamp long descriptions that people skim, such as the details of a ticket type.
Don’t
Don't clamp what people must read before they buy: terms, prices, fees or entry conditions. Show it in full.
aria-expanded and aria-controls pointing at the panel. Enter or Space toggles it.keepMounted or hiddenUntilFound. With hiddenUntilFound, find in page can match the closed text and opens the panel to show it.Collapsible.Text keeps the whole text in the page, so screen readers and find in page reach all of it. Its trigger is a button with aria-expanded and aria-controls pointing at the text, and focus stays on it as it toggles. The ellipsis is decorative. With lessLabel={null} the trigger goes once the text expands, and focus moves to the text.Whether the collapsible panel is currently open. To render an uncontrolled collapsible, use the `defaultOpen` prop instead.
Whether the collapsible panel is initially open. To render a controlled collapsible, use the `open` prop instead.
Defaults to false.
Event handler called when the panel is opened or closed.
Whether the component should ignore user interaction.
Defaults to false.
CSS class applied to the element, or a function that returns a class based on the component's state.
CSS class applied to the element, or a function that returns a class based on the component's state.
Inherited from CollapsiblePanelProps
Allows the browser's built-in page search to find and expand the panel contents. Overrides the `keepMounted` prop and uses `hidden="until-found"` to hide the element without removing it from the DOM.
Defaults to false.
Whether to keep the element in the DOM while the panel is hidden. This prop is ignored when `hiddenUntilFound` is used.
Defaults to false.
How many lines show while closed.
Defaults to 3.
The closed trigger's label, shown after a decorative ellipsis.
Defaults to more.
The open trigger's label. `null` expands only, with no way back.
Defaults to Show less.
Swap the paragraph for another element, such as `<div />`.
CSS class applied to the element, or a function that returns a class based on the component's state.
Show a trailing caret that turns when the panel opens.
Defaults to true.
Inherited from NativeButtonProps
Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).
Defaults to true.