Skip to content

feat(core): add dom attributes option for nodes #1861

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

Conversation

cmath10
Copy link
Contributor

@cmath10 cmath10 commented May 23, 2025

🚀 What's changed?

Added the possibility to customize HTML attributes of .vue-flow__node elements, globally through the nodesAttributes prop, and for each single node.

🐛 Fixes

None

🪴 To-Dos

None

Motivation

For my use case, I need greater flexibility in customizing ARIA attributes — for example, being able to explicitly set a role or provide additional aria-* properties.

Currently, role="button" is set automatically when focusable is true and omitted otherwise, with no way to override this behavior. While aria-label can be configured, this alone is often not sufficient for proper accessibility. Other attributes, such as aria-describedby, are managed internally and cannot be customized externally, which limits the ability to implement more advanced accessibility patterns.

According to WAI-ARIA specifications, for example, aria-describedby may include multiple ID references — something that is currently not supported via the API.

This PR is intended as a starting point for discussion, and I’m open to feedback on how to make this more flexible while fitting within the existing design.

@cmath10 cmath10 requested a review from bcakmakoglu as a code owner May 23, 2025 14:15
Copy link

codesandbox bot commented May 23, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

changeset-bot bot commented May 23, 2025

⚠️ No Changeset found

Latest commit: 903439f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented May 23, 2025

@cmath10 is attempting to deploy a commit to the Burak Cakmakoglu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@bcakmakoglu
Copy link
Owner

Thanks for the PR - I'll have a look although I can't promise it lands since VueFlow 1.x is technically in a feature freeze so I usually only accept bugfix PRs atm :/ (I should add a warning for this to the repo, my bad ^^)

Although this looks like a rather small change so this might be fine, but again no promises, sorry.

Customizing a11y attributes will be possible in 2.x though which should be released some time this year so whether this lands or not you will get the ability to customize them to your liking at some point either way.

@bcakmakoglu
Copy link
Owner

I will consider adding this feature to VueFlow 1.x
After deliberation with the XYFlow team we agreed that this idea is useful and will most likely be added to ReactFlow/SvelteFlow as well and I don't wanna have people wait for VF 2.x since it will probably be a while before it is released.

Will report back here once I finally decided to move forward with this or not ^^

@bcakmakoglu bcakmakoglu changed the title feat: Possibility to customize HTML attributes for nodes feat(core): add dom attributes option for nodes Jun 10, 2025
@bcakmakoglu bcakmakoglu changed the base branch from master to next-release June 10, 2025 10:02
@bcakmakoglu
Copy link
Owner

I will be adding this with a couple changes though:

  1. No global nodeAttributes object - define it per node as node.domAttrs
  2. Typing is slightly more narrow
  3. Added edge.domAttrs as well so the same can be done for edges

@bcakmakoglu bcakmakoglu merged commit a31812b into bcakmakoglu:next-release Jun 10, 2025
2 of 3 checks passed
bcakmakoglu pushed a commit that referenced this pull request Jun 10, 2025
bcakmakoglu pushed a commit that referenced this pull request Jun 10, 2025
bcakmakoglu added a commit that referenced this pull request Jun 10, 2025
* feat(core): add dom attributes option for nodes and edges (#1861)

Signed-off-by: braks <[email protected]>

* chore(changeset): add

* chore: cleanup

Signed-off-by: braks <[email protected]>

---------

Signed-off-by: braks <[email protected]>
Co-authored-by: Kirill Zaytsev <[email protected]>
bcakmakoglu pushed a commit that referenced this pull request Jun 10, 2025
feat: Possibility to customize nodes HTML attributes
bcakmakoglu added a commit that referenced this pull request Jun 10, 2025
* feat(core): add dom attributes option for nodes and edges (#1861)

Signed-off-by: braks <[email protected]>

* chore(changeset): add

* chore: cleanup

Signed-off-by: braks <[email protected]>

---------

Signed-off-by: braks <[email protected]>
Co-authored-by: Kirill Zaytsev <[email protected]>
@bcakmakoglu
Copy link
Owner

This is released in 1.45.0 :)

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

Successfully merging this pull request may close these issues.

2 participants