How to Programmatically Control Accordion Open/Close State with External Props? #595
-
Hello, I'm working with the Accordion component from the Shadcn library in a Vue 3 project and I'm trying to find a way to programmatically open and close accordion sections from an external function or by setting a prop. My goal is to control the accordion based on the state changes in another part of my application, such as checkbox selections. Current Setup: Is there a recommended way to control the accordion's open/close state externally through props or an API method? I've tried directly setting a reactive property bound to the value of the Accordion, but it doesn't seem to trigger the accordion state changes as expected. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
https://stackblitz.com/edit/dp1hww?file=src%2FApp.vue You can use Checkbox
to communicate between these two components |
Beta Was this translation helpful? Give feedback.
https://stackblitz.com/edit/dp1hww?file=src%2FApp.vue
You can use Checkbox
@update:checked
emit to control Accrodion component (controlled component)If Checkbox and Accordion are not in the same Vue file you can use
to communicate between these two components