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

Title ID to enhance the SVG a11y #360

Closed
elizabetdev opened this issue Nov 22, 2019 · 3 comments
Closed

Title ID to enhance the SVG a11y #360

elizabetdev opened this issue Nov 22, 2019 · 3 comments
Labels

Comments

@elizabetdev
Copy link

🚀 Feature Proposal

Hi there! 👋 First of all, thanks for creating this amazing project!

I want to propose the ability to add unique id for every single <title> tag. So we can use correctly the aria-labelledby.

If we want to use the aria-labelledby that is recommended to enhance the SVG accessibility we can't because the aria-labelledby needs to target the id from the title tag.

I propose a new config option called titleId.

Example

In our config file, we would have something like:

  svgoConfig: {
    plugins: [
      { cleanupIDs: false }
    ]
  },
  svgProps: {
    xmlns: "http://www.w3.org/2000/svg"
  },
  titleProp: true,
  titleId: filePath // the user can specify a uniqueId

This would generate a component like:

const IconStar = ({ title, ...props }) => (
  <svg
    width={16}
    height={16}
    viewBox="0 0 16 16"
    xmlns="http://www.w3.org/2000/svg"
    {...props}
  >
    <title id="IconStar">{title}</title>
    <path
      fillRule="evenodd"
      d="..."
    />
  </svg>
);
@gregberge
Copy link
Owner

Hello @miukimiu, it is a good idea. The problem is that ids are actually a problem because they have to be unique. So the best way to provide this support is probably to inject a titleId property. This way it could be specified as property.

@gregberge gregberge added the v5 Released in v5 label Dec 23, 2019
@elizabetdev
Copy link
Author

Thanks for this! 🎉

@KatSick
Copy link

KatSick commented Oct 7, 2022

@gregberge I can't find titleId property in 6.4.0 version. how can I pass custom titleId property via nodejs api?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants