A section that opens and closes under its trigger (<.collapse>) and a text clamped to a few
lines with a "show more" link (<.collapse_text>).
<.collapse id="details">
<:trigger>Shipping details</:trigger>
<p>Ships in two days.</p>
</.collapse>
<.collapse id="files" open chevron="down" variant="section">
<:trigger>My files</:trigger>
...
</.collapse>
<.collapse_text id="desc" lines={2} more="Show more" less="Show less">
Long text...
</.collapse_text>collapse is a native <details>: the trigger works with the mouse and the keyboard and the
browser owns open; when the server changes open, the server wins. LedgerUI.open/close/toggle("id")
open and close it too. on_open / on_close run on every toggle (an event name pushes
%{"id" => id} to the LiveView or target; a %JS{} is run as is). The LedgerUI.Collapse hook
(priv/static/ledger_ui/hooks/collapse.js) provides the events and the chevron's turn.
variant is the design canvas section by default; classic (or nil) leaves the trigger to its
class; framed, flat and section are the other ready-made looks.
Summary
Functions
A text clamped to lines lines, with a link under it that shows the rest and hides it again.
Works in the browser (no event to the server); the link has aria-expanded and aria-controls.
Functions
Attributes
id(:string) (required)open(:boolean) - Defaults tofalse.on_open(:any) - Defaults tonil.on_close(:any) - Defaults tonil.target(:any) - Defaults tonil.chevron(:string) - Defaults tonil.Must be one ofnil,"","down", or"right".variant(:string) - Defaults to"canvas". Must be one ofnil,"","classic","framed","flat","section", or"canvas".panel_class(:any) - Defaults tonil.chevron_class(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)trigger(required) - Accepts attributes:class(:any)style(:string)
A text clamped to lines lines, with a link under it that shows the rest and hides it again.
Works in the browser (no event to the server); the link has aria-expanded and aria-controls.
Attributes
id(:string) (required)lines(:integer) - Defaults to2.open(:boolean) - Defaults tofalse.more(:string) - Defaults to"Show more".less(:string) - Defaults to"Show less".class(:any) - Defaults tonil.text_class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)