diff --git a/docs/components/details.md b/docs/components/details.md index 9d5fb63ce..4181659d9 100644 --- a/docs/components/details.md +++ b/docs/components/details.md @@ -46,6 +46,30 @@ const App = () => ( ); ``` +### Customizing the Summary Icon + +Use the `summary-icon` slot to change the summary icon. You can use `` or your own SVG. By default, the icon will rotate 90ยบ when the details opens and closes. If desired, you can style the `summary-icon` part to change the animation. + +```html preview + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + +``` + +```jsx react +import { SlDetails, SlIcon } from '@shoelace-style/shoelace/dist/react'; + +const App = () => ( + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + +); +``` + ### Grouping Details Details are designed to function independently, but you can simulate a group or "accordion" where only one is shown at a time by listening for the `sl-show` event. diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index 10ad4e76c..65951f5b3 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -11,6 +11,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti ## Next - Added `header-actions` slot to `` and `` +- Added the `summary-icon` slot to `` [#1046](https://github.com/shoelace-style/shoelace/discussions/1046) - Fixed a bug in `` where `sl-selection-change` was emitted when the selection didn't change [#1030](https://github.com/shoelace-style/shoelace/pull/1030) - Fixed a bug in `` that caused the border to render incorrectly when hovering over icons inside buttons [#1035](https://github.com/shoelace-style/shoelace/issues/1035) - Fixed an incorrect default for `flip-fallback-strategy` in `` that caused the fallback strategy to be `initial` instead of `best-fit`, which is inconsistent with Floating UI's default [#1036](https://github.com/shoelace-style/shoelace/issues/1036) diff --git a/src/components/details/details.styles.ts b/src/components/details/details.styles.ts index 8a01a80d8..8d0ca9a68 100644 --- a/src/components/details/details.styles.ts +++ b/src/components/details/details.styles.ts @@ -56,11 +56,11 @@ export default css` flex: 0 0 auto; display: flex; align-items: center; - transition: var(--sl-transition-medium) transform ease; + transition: var(--sl-transition-medium) rotate ease; } .details--open .details__summary-icon { - transform: rotate(90deg); + rotate: 90deg; } .details__body { diff --git a/src/components/details/details.ts b/src/components/details/details.ts index fd416ff91..b2f0079a3 100644 --- a/src/components/details/details.ts +++ b/src/components/details/details.ts @@ -21,6 +21,7 @@ import type { CSSResultGroup } from 'lit'; * * @slot - The details' content. * @slot summary - The details' summary. Alternatively, you can use the `summary` attribute. + * @slot summary-icon - The icon to show next to the summary. * * @event sl-show - Emitted when the details opens. * @event sl-after-show - Emitted after the details opens and all animations are complete. @@ -173,13 +174,11 @@ export default class SlDetails extends ShoelaceElement { @click=${this.handleSummaryClick} @keydown=${this.handleSummaryKeyDown} > -
- ${this.summary} -
+ ${this.summary} - + - +