-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[accordion] New Accordion components and hooks (#577)
Co-authored-by: Olivier Tassinari <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michał Dudak <[email protected]> Co-authored-by: atomiks <[email protected]>
- Loading branch information
1 parent
dd67366
commit 8054a85
Showing
118 changed files
with
4,308 additions
and
1,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionHeader", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionHeader = Accordion.Header;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionHeader", | ||
"forwardsRefTo": "HTMLHeadingElement", | ||
"filename": "/packages/mui-base/src/Accordion/Header/AccordionHeader.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionHeading", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionHeading = Accordion.Heading;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionHeading", | ||
"forwardsRefTo": "HTMLHeadingElement", | ||
"filename": "/packages/mui-base/src/Accordion/Heading/AccordionHeading.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"disabled": { "type": { "name": "bool" }, "default": "false" }, | ||
"onOpenChange": { "type": { "name": "func" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionItem", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionItem = Accordion.Item;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionItem", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Accordion/Item/AccordionItem.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"hiddenUntilFound": { "type": { "name": "bool" }, "default": "false" }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionPanel", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionPanel = Accordion.Panel;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionPanel", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Accordion/Panel/AccordionPanel.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"props": { | ||
"animated": { "type": { "name": "bool" }, "default": "true" }, | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"defaultValue": { | ||
"type": { "name": "arrayOf", "description": "Array<number<br>| string>" }, | ||
"default": "0" | ||
}, | ||
"disabled": { "type": { "name": "bool" }, "default": "false" }, | ||
"loop": { "type": { "name": "bool" }, "default": "true" }, | ||
"onValueChange": { "type": { "name": "func" } }, | ||
"openMultiple": { "type": { "name": "bool" }, "default": "true" }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } }, | ||
"value": { | ||
"type": { "name": "arrayOf", "description": "Array<number<br>| string>" } | ||
} | ||
}, | ||
"name": "AccordionRoot", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionRoot = Accordion.Root;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionRoot", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Accordion/Root/AccordionRoot.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"disabled": { "type": { "name": "bool" }, "default": "false" }, | ||
"onOpenChange": { "type": { "name": "func" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionSection", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionSection = Accordion.Section;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionSection", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Accordion/Section/AccordionSection.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "AccordionTrigger", | ||
"imports": [ | ||
"import { Accordion } from '@base_ui/react/Accordion';\nconst AccordionTrigger = Accordion.Trigger;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "AccordionTrigger", | ||
"forwardsRefTo": "HTMLButtonElement", | ||
"filename": "/packages/mui-base/src/Accordion/Trigger/AccordionTrigger.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-accordion/\">Accordion</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"hiddenUntilFound": { "type": { "name": "bool" }, "default": "false" }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "CollapsiblePanel", | ||
"imports": [ | ||
"import { Collapsible } from '@base_ui/react/Collapsible';\nconst CollapsiblePanel = Collapsible.Panel;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "CollapsiblePanel", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Collapsible/Panel/CollapsiblePanel.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-collapsible/\">Collapsible</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"parameters": {}, | ||
"returnValue": {}, | ||
"name": "useAccordionRoot", | ||
"filename": "/packages/mui-base/src/Accordion/Root/useAccordionRoot.ts", | ||
"imports": ["import { useAccordionRoot } from '@base_ui/react/Accordion';"], | ||
"demos": "<ul><li><a href=\"/base-ui/react-accordion/#hook\">Accordion</a></li></ul>" | ||
} |
61 changes: 61 additions & 0 deletions
61
docs/data/components/accordion/UnstyledAccordionIntroduction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Accordion } from '@base_ui/react/Accordion'; | ||
import classes from './styles.module.css'; | ||
|
||
export default function UnstyledAccordionIntroduction() { | ||
return ( | ||
<div className={classes.demo}> | ||
<Accordion.Root className={classes.root} aria-label="Base UI Accordion"> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 1</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 1 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 2</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 2 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 3</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 3 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
</Accordion.Root> | ||
</div> | ||
); | ||
} | ||
|
||
function ExpandMoreIcon(props) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
> | ||
<path d="M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z" fill="currentColor" /> | ||
</svg> | ||
); | ||
} |
61 changes: 61 additions & 0 deletions
61
docs/data/components/accordion/UnstyledAccordionIntroduction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Accordion } from '@base_ui/react/Accordion'; | ||
import classes from './styles.module.css'; | ||
|
||
export default function UnstyledAccordionIntroduction() { | ||
return ( | ||
<div className={classes.demo}> | ||
<Accordion.Root className={classes.root} aria-label="Base UI Accordion"> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 1</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 1 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 2</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 2 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
<Accordion.Item className={classes.item}> | ||
<Accordion.Header className={classes.header}> | ||
<Accordion.Trigger className={classes.trigger}> | ||
<span className={classes.triggerText}>Trigger 3</span> | ||
<ExpandMoreIcon /> | ||
</Accordion.Trigger> | ||
</Accordion.Header> | ||
<Accordion.Panel className={classes.panel}> | ||
This is the contents of Accordion.Panel 3 | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
</Accordion.Root> | ||
</div> | ||
); | ||
} | ||
|
||
function ExpandMoreIcon(props: React.SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
> | ||
<path d="M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z" fill="currentColor" /> | ||
</svg> | ||
); | ||
} |
Oops, something went wrong.