Skip to content

Commit

Permalink
docs(accordion): document how to animate accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed Feb 27, 2024
1 parent 7ddc29e commit 31df808
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/website/src/content/components/accordion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ Understanding the Accordion's anatomy is crucial for proper setup:
<Anatomy id="accordion" />

## Animation

You can use CSS animations to create smooth transitions for opening and closing Accordion items. Utilize the `data-state` attribute in combination with the `--height` CSS variable to animate the open and closed states of `Accordion.ItemContent`.

```css
@keyframes slideDown {
from { height: 0; }
to { height: var(--height); }
}

@keyframes slideUp {
from { height: var(--height); }
to { height: 0; }
}

[data-scope='accordion'][data-part='item-content'][data-state='open'] {
animation: slideDown 250ms;
}

[data-scope='accordion'][data-part='item-content'][data-state='closed'] {
animation: slideUp 200ms;
}
```

## Examples

### Collapsible Panels
Expand Down

0 comments on commit 31df808

Please sign in to comment.