All components (283)
Collapsible text
Utilities · Spoiler
What it is and when to use it
A long text clipped with a "Show more". The button only appears if it is really cut: a short text is seen in full and without a button, without knowing beforehand how much it measures.
When to use it
- Product descriptions, biographies, terms: what can be short or very long.
maxHeightis what is seen collapsed, in pixels.showLabelandhideLabelchange the button text.
When not to
- Several sections with their title:
Accordion. - A title that opens and closes a block:
Collapsible.
Keyboard: Tab reaches the button; Enter and Space expand.
Accessibility: the button says with aria-expanded whether it is open and points to the text with aria-controls. What is collapsed stays in the document: a screen reader reads it and the browser's search finds it.
Fine-tuning: no variables of its own: it is adjusted with the amset-spoiler__body and amset-spoiler__toggle classes.
What it looks like
Every piece is made by hand in our Seville workshop, in 925 sterling silver. The engraving is done by machine and finished by hand, so no two pieces come out exactly alike. Orders ship within 48 working hours in a recycled cardboard box. If you're not happy with it, you have 30 days to return it with no questions asked: we pick it up from your home and refund you as soon as it reaches the workshop.
We ship across mainland Spain within 48 working hours and to the Balearic Islands within 72. Orders over €50 ship free. If you're not home, the courier leaves a note and you can collect the parcel at the nearest office within seven days or request a second delivery from the tracking link we email you.
<Spoiler maxHeight={72} showLabel="Show more" hideLabel="Show less">
<p>{descripcion}</p>
</Spoiler>Props
Import it with import { Spoiler } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
childrenrequired | ReactNode | — |
className | string | Merged with the library classes; it does not replace them. |
defaultExpanded | boolean | — |
expanded | boolean | Controlled. |
hideAriaLabel | string | — |
hideLabel | string | By default, "Show less". |
maxHeight | string | number | What shows while folded: a number is pixels; a string, any CSS unit («6rem», «4lh»). Defaults to 120. |
onExpandedChange | (expanded: boolean) => void | — |
showAriaLabel | string | What a screen reader reads on the button when the visible text is not enough: «Show more of the description». |
showLabel | string | By default, "Show more". |
toggleRef | Ref<HTMLButtonElement> | The button node, to move focus to it or measure it. |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
In the test bench
Every state and variant, to try one at a time, on its page at storybook.amsetui.com:
