Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Access state exposed only via data-attributes #1549

Open
2 tasks
thomasaull opened this issue Jan 9, 2025 · 0 comments
Open
2 tasks

[Feature]: Access state exposed only via data-attributes #1549

thomasaull opened this issue Jan 9, 2025 · 0 comments

Comments

@thomasaull
Copy link

thomasaull commented Jan 9, 2025

Describe the feature

I'm currently implementing Calendar and Date Picker components in a project and I'm not sure how to tackle this problem in the best way possible. To give you an example (please note that this exists in many more places):

  • I have a component MyButton.vue which I want to use as the prev/next buttons for the calendar component
  • MyButton has a prop for a disabled state
  • The CalendarPrev of radix-vue has a state disabled, which is only exposed as a data-attribute [data-disabled]

My question now is, how to handle this case, where the state disabled is only exposed as a data-attribute but I want to forward it to my component as a prop?

Some ideas:

  1. Use both the prop and the data-attribute for styling in the MyButton component (which I don’t really want to do, since the component should stay independent to the parent components implementing it. Also it could introduce additional styling bugs)
  2. Create some sort of composable to reactively read the data attributes from an element
  3. Recreate the behaviour of disabled with my own logic
  4. radix-vue exposes the state in other ways aswell, for example as slots or by making contexts available

Any advice?

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant