nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
21.97k stars 1.54k forks source link

[Feature Request] Add locale prop to components with href prop #3599

Open nerilea opened 3 months ago

nerilea commented 3 months ago

Is your feature request related to a problem? Please describe.

For proper support of multi-locale sites components that render as <a> elements should support the locale prop to allow switching the locale.

I am implementing a locale/language switcher in a Dropdown. I currently cannot use the href prop of the <DropdownItem> component because it does not support a locale attribute. Using keyboard navigation does not activate nested <Link> components so a separate onPress event was needed to achieve the desired behavior.

Describe the solution you'd like

I would like to be able to use NextUI components that are capable of rendering as <a> elements the same way I would use a <Link> component

ex:

<DropdownItem
  href={location}
  locale={lang}
>
  {lang}
</DropdownItem>

Describe alternatives you've considered

Current work around I am using is to implement the onPress event while also leaving the <Link> component so the url will be displayed on the bottom corner of the browser when hovering over the link.

<DropdownItem
  textValue={lang}
  onPress={() => router.push(location, { locale: lang })}
>
  <Link
    href={location}
    locale={lang}
  >
    {lang}
  </Link>
</DropdownItem>

Screenshots or Videos

No response

linear[bot] commented 3 months ago

ENG-1241 [Feature Request] Add locale prop to components with href prop