You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as should allow for passing any HTML tag name and would swap out the outermost element for whatever the user passes in.
Why?
Two reasons:
A lot of minor a11y issues come from needing a different tag around a component. Sometimes the component can simply be wrapped by the consuming app (e.g., when the component is a div or something equally semantically empty) but other times that would change the meaning (e.g., when the component provides a semantically meaningful tag).
Could be a nice dev convenience — reducing the amount of tag/component nesting just to get the right structure (e.g., instead of <EuiScreenreaderOnly><p>{text}</p></EuiScreenreadOnly> we can reduce a level of nesting by using <EuiScreenreaderOnly as="p">{text}</EuiScreenreadOnly>.
Inspired to open this issue by ongoing discussion in #4413 but I know the thought has crossed my mind before too so it seemed like time to open an issue for it.
Reacted by Greg Thompson, Elizabet Oliveira and Caroline Horn
I'm not married to as being the prop name. If component is already in use in some places than keeping that might be worth it (though the naming does seem a little unclear imo). tag, wrappingTag, outerTag also come to mind as maybe more descriptive name options.
The main thing here is to expose this prop on every EUI component.
The boilerplate it requires is one thing but I am also kind of nervous of what happens to types with all this. EUI's types can be quite complicated sometimes and this will only make them more-so, I imagine.
And another thing that'll need to be figured out is whether or not actually to expose this on every component or only components that have some sort of wrapping element. Like, does it make sense to have this prop on EuiButton or any of the form elements? Probably not... But should we for consistency's sake? 🤷♂️
If people largely think this is a good idea, then we can start to explore those caveats and hammer out the details.
as is the common pattern across libraries, regardless of other action we should deprecate the existing component props and replace with as
I'd hesitate to make this a sweeping, blanket change across every component. We have decided on strict tag/element usage in some cases for very specific reasons including semantics, screen reading, and keyboard accessibility. Allowing these components to be changed seems too reactive; EuiLink & EuiButton come to mind.
Agreeing with a previous comment, we'd want to find a way to enable this on components with as little boilerplate as we can
TypeScript support may suffer. It's very possible the "least boilerplate" approach means passing as loses a lot of type checking.
Coming back to what components we would or wouldn't do this with, we should get a feel for which we'd expect to include in the change.
+++++ To all the points made and only adding that, I like the approach and direction it's heading. I've seen this pattern work well with things like Chakra UI, but do worry about the Typescript part of it. So a "pattern" or "service" that will help us to use the same setup in components where we want it will be ideal.
I'm actually running into this right now where I really would like EuiPanel to render as a different element like <main> for the page layout stuff. I tried re-creating how EuiPageBody is handling it, but ran into issues when the panel could be a button because of an onClick.
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
Activity
snide commentedon Jan 6, 2021
Good idea! The naming pattern we've followed for this is
component, and then we've named themElementinside. It's in use in several of the components similar to https://github.com/elastic/eui/blob/master/src/components/form/form.tsx. I bring it up not to advocate keeping that pattern, but to acknowledge we'd need to migrate from it if we shifted.Likely the devil is in the details here. It'd be nice to not have to write all the boilerplate we usually do...
myasonik commentedon Jan 7, 2021
I'm not married to
asbeing the prop name. Ifcomponentis already in use in some places than keeping that might be worth it (though the naming does seem a little unclear imo).tag,wrappingTag,outerTagalso come to mind as maybe more descriptive name options.The main thing here is to expose this prop on every EUI component.
The boilerplate it requires is one thing but I am also kind of nervous of what happens to types with all this. EUI's types can be quite complicated sometimes and this will only make them more-so, I imagine.
And another thing that'll need to be figured out is whether or not actually to expose this on every component or only components that have some sort of wrapping element. Like, does it make sense to have this prop on
EuiButtonor any of the form elements? Probably not... But should we for consistency's sake? 🤷♂️If people largely think this is a good idea, then we can start to explore those caveats and hammer out the details.
chandlerprall commentedon Jan 7, 2021
I'm on board overall, some quick thoughts:
asis the common pattern across libraries, regardless of other action we should deprecate the existingcomponentprops and replace withasI'd hesitate to make this a sweeping, blanket change across every component. We have decided on strict tag/element usage in some cases for very specific reasons including semantics, screen reading, and keyboard accessibility. Allowing these components to be changed seems too reactive; EuiLink & EuiButton come to mind.
Agreeing with a previous comment, we'd want to find a way to enable this on components with as little boilerplate as we can
TypeScript support may suffer. It's very possible the "least boilerplate" approach means passing
asloses a lot of type checking.Coming back to what components we would or wouldn't do this with, we should get a feel for which we'd expect to include in the change.
cchaos commentedon Jan 11, 2021
+++++ To all the points made and only adding that, I like the approach and direction it's heading. I've seen this pattern work well with things like Chakra UI, but do worry about the Typescript part of it. So a "pattern" or "service" that will help us to use the same setup in components where we want it will be ideal.
cchaos commentedon Feb 16, 2021
I'm actually running into this right now where I really would like EuiPanel to render
asa different element like<main>for the page layout stuff. I tried re-creating how EuiPageBody is handling it, but ran into issues when the panel could be a button because of anonClick.cchaos commentedon Feb 23, 2021
I think mostly what I'm looking for at the moment, is a repeatable TS pattern we can start using in components where we want this behavior.
snide commentedon Feb 23, 2021
Another example of where this came up (with avatars).
#4549 (comment)
cchaos commentedon Mar 19, 2021
Just as a note, this is going to be pretty tricky to get right with Typescript.
For example, just about this whole folder by Tailwind is dedicated to supporting this in TS: https://github.com/tailwindlabs/headlessui/tree/main/packages/%40headlessui-react/src/utils
github-actions commentedon Sep 16, 2021
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
cchaos commentedon Sep 16, 2021
We really need some general guidance on this. Have we found a pattern that we like yet? If so, can we document it?
github-actions commentedon Mar 15, 2022
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
github-actions commentedon Sep 12, 2022
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.
github-actions commentedon Sep 19, 2022
❌ We're automatically closing this issue due to lack of activity. Please comment if you feel this was done in error.