diff --git a/packages/docs/pages/components/Collapse.md b/packages/docs/pages/components/Collapse.md index 7adebdc45..449abdd66 100644 --- a/packages/docs/pages/components/Collapse.md +++ b/packages/docs/pages/components/Collapse.md @@ -4,9 +4,9 @@
-The **Collapse** component is an easy way to toggle the visibility of content with show/hide functionality. -It has two elements: a disclosure button and a section of content whose visibility is controlled by the button. -The component implements the W3C ARIA APG [Disclosure (Show/Hide) Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) and also supports the W3C ARIA APG [Accordion Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/). +The **Collapse** component (also known as _accordion_) is a disclosure widget which is used to toggle the display of further information. +The component is implemented based on the [HTML \ element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details) and consists of two elements: a short disclosure label (trigger) and a section of content whose visibility it controls; the content can be 'collapsed' or 'expanded'. +This component implements the W3C ARIA APG [Disclosure (Show/Hide) Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/) and also supports the W3C ARIA APG [Accordion Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/).
@@ -22,7 +22,7 @@ The component implements the W3C ARIA APG [Disclosure (Show/Hide) Pattern](https ## Collapse Component -> An easy way to toggle what you want. +> An easy disclosure widget to toggle content visability. ```html @@ -30,23 +30,24 @@ The component implements the W3C ARIA APG [Disclosure (Show/Hide) Pattern](https ### Props -| Prop name | Description | Type | Values | Default | -| --------- | ---------------------------------------------------------------------------- | ----------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| animation | Custom animation (transition name) | string | - |
From config:
collapse: {
  animation: "fade"
}
| -| contentId | Id property of the content container - default is an uuid | string | - | useId() | -| expanded | Expand the trigger to fullwidth | boolean | - | false | -| open | Whether collapse is open or not, use v-model:open to make it two-way binding | boolean | - | true | -| override | Override existing theme classes completely | boolean | - | | -| position | Trigger position | "bottom" \| "top" | `top`, `bottom` |
From config:
collapse: {
  position: "top"
}
| -| triggerId | Id property of the trigger container - default is an uuid | string | - | useId() | +| Prop name | Description | Type | Values | Default | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| contentId | Id property of the content container - default is an uuid | string | - | useId() | +| expanded | Expand the trigger to fullwidth | boolean | - | false | +| label | Some label displayed in the summary element - unnecessary when trigger slot is used | string | - | | +| name | Setting the same name to multiple collapse elements connects them together,
with only one open at a time.
This allows to easily create UI features such as accordions. | string | - | | +| open | Whether collapse is open or not, use v-model:open to make it two-way binding | boolean | - | false | +| override | Override existing theme classes completely | boolean | - | | +| position | Trigger position | "bottom" \| "top" | `top`, `bottom` |
From config:
collapse: {
  position: "bottom"
}
| +| triggerId | Id property of the trigger container - default is an uuid | string | - | useId() | ### Events -| Event name | Properties | Description | -| ----------- | --------------------------------------- | ------------------------- | -| update:open | **value** `boolean` - updated open prop | open prop two-way binding | -| open | | on collapse opened | -| close | | on collapse closed | +| Event name | Properties | Description | +| ----------- | ------------------------------------------------- | ------------------------- | +| update:open | **value** `boolean` - updated open prop | open prop two-way binding | +| open | **event** `ToggleEvent` - the native toggle event | on collapse opened | +| close | **event** `ToggleEvent` - the native toggle event | on collapse closed | ### Slots diff --git a/packages/oruga/src/components/collapse/Collapse.vue b/packages/oruga/src/components/collapse/Collapse.vue index fde2f38df..a45272a08 100644 --- a/packages/oruga/src/components/collapse/Collapse.vue +++ b/packages/oruga/src/components/collapse/Collapse.vue @@ -1,5 +1,5 @@ diff --git a/packages/oruga/src/components/collapse/examples/accordion.vue b/packages/oruga/src/components/collapse/examples/accordion.vue index 53f7bc71d..a420c96d6 100644 --- a/packages/oruga/src/components/collapse/examples/accordion.vue +++ b/packages/oruga/src/components/collapse/examples/accordion.vue @@ -1,14 +1,12 @@ ### Base -A custom trigger can be passed in the `trigger` slot. +A custom trigger can be passed in the `trigger` slot oder by the `label` property. +When the controlled content is hidden, the trigger is often styled as a typical push button with a right-pointing arrow or triangle, to indicate that activating the trigger will display the hidden content. +When the content is visible, the arrow or triangle usually points down. ::: info Accessibility Note: -The trigger container is already an interactive element with the `role="button"` attribute. For accessibility reasons, prevent adding other interactive elements such as buttons to avoid [nested-interactive](https://accessibilityinsights.io/info-examples/web/nested-interactive/) accessibility problems. +The trigger container is already an interactive element with the `role="button"` attribute. For accessibility reasons, prevent adding other interactive elements such as buttons in the `trigger` slot to avoid [nested-interactive](https://accessibilityinsights.io/info-examples/web/nested-interactive/) accessibility problems. ::: +### Position + +The collapse can be configured by the `position` property to open to top instead of bottom. + + + ### Accordion -Combine multiple collapse components to create an accordion behaviour. +Using the [`name`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details#name) property multiple collapse components can be connected to create an accordion behaviour, with only one content open at a time. diff --git a/packages/oruga/src/components/collapse/examples/inspector.vue b/packages/oruga/src/components/collapse/examples/inspector.vue index 95456e3c1..ebb4cc782 100644 --- a/packages/oruga/src/components/collapse/examples/inspector.vue +++ b/packages/oruga/src/components/collapse/examples/inspector.vue @@ -36,25 +36,15 @@ const inspectData: InspectData = {