Hello.
I love styled components, and use mainly my components and sometimes Rebass.
I think an article or something to talk about reas in comparison with Rebass can be usefull.
Thank you for the work on reas !
Hi, @romainquellec. I can write a more detailed article, but here are some thoughts:
reas can be amazing in the future, but right now it's an experimental project (hence v0.0.x). Rebass seems to be more consolidated, ready to use in production;
Probably, Rebass is more performatic than reas. I'm not sure about that because I still didn't measure perfomance here (any help is welcome ๐);
Rebass has an is prop that changes the underlying HTML element. From reas side, as is more powerful, that's the core functionality here. Besides just replacing the element, it can combine multiple components;
reas isn't just a bunch of components. It's a component system. You can easily create your own components with all reas goodies by just using the as enhancer:
const MyComponent = ({ as: T, ...props }) => <T {...props} />
export default as('span')(MyComponent)
As far as I know, Rebass doesn't provide stuff for you to control the state of your components. You must implement it by yourself. While all reas components are stateless, the lib provides state enhancers and behavior components to ease that work. Of course, you can always implement it by yourself, using React state, redux, mobx or anything else;
Rebass components aren't WAI-ARIA compliant by default.
cc @jxnblk
Definitely intrigued by this library, but I'll chime in to how I see these as being different concepts.
Button.extendRebass has an is prop that changes the underlying HTML element. From reas side, as is more powerful, that's the core functionality here. Besides just replacing the element, it can combine multiple components;
This is probably the thing I understand least about reas (and am most curious about) โ I don't understand what it does nor why I would want this. Would love to see some more documentation and explanation for the rationale here in the docs. I'm planning on taking a look later, so forgive my ignorance.
For Rebass, I've preferred to keep things a little more React-like by using props. If you want to change the underlying element, you can do things like this:
const ButtonLink = props => <Button is='a' {...props} />
As far as I know, Rebass doesn't provide stuff for you to control the state of your components. You must implement it by yourself. While all reas components are stateless, the lib provides state enhancers and behavior components to ease that work. Of course, you can always implement it by yourself, using React state, redux, mobx or anything else;
This is correct, but architecturally I don't think it makes sense to keep state in low-level UI components like Rebass. For applications, I try to make good use of React's functional setState and have a small library that wraps some of that sort of thing up here: https://github.com/jxnblk/refunk
Rebass components aren't WAI-ARIA compliant by default.
I'm not sure I understand what reas does to be WAI-ARIA compliant by default โ I think there's a lot of general misunderstanding about accessibility in the field and want to clarify that it's not really feasible to have accessibility features built in to Rebass beyond what it does now. Rebass uses semantic HTML elements where appropriate, so there's no need for aria attributes (when you use the Input for forms for example), but you do need to handle accessibility on your end, just as with any other HTML you may write. E.g. if you have an <img> tag, you need an alt attribute, and with Rebass, you should use alt attributes on the Image component.
Anyway, hope that's helpful, and I'm curious to see where you go with this library
Thank you for commenting, @jxnblk.
This is probably the thing I understand least about reas (and am most curious about) โ I don't understand what it does nor why I would want this. Would love to see some more documentation and explanation for the rationale here in the docs. I'm planning on taking a look later, so forgive my ignorance.
Documentation should be improved for sure. as is inspired by Semantic-UI's augmentation feature, which is very similar to Rebass is. In reas, it does the same thing, except that it also accepts an array of components.
Besides that, it can be used in different ways, for example:
Component.as(string | string[])const ButtonLink = Button.as('a')
```
<Component as={string | string[]} />const ButtonLink = props =>
```
as(string | string[])(Component)const ButtonLink = as('a')(Button)
```
Maybe we should focus on just one API. But, as a good experiment, I would like to see how people will use it.
I think there's a lot of general misunderstanding about accessibility in the field and want to clarify that it's not really feasible to have accessibility features built in to Rebass beyond what it does now. Rebass uses semantic HTML elements where appropriate, so there's no need for aria attributes
By "WAI-ARIA compliant by default" I mean applying roles and aria attributes on those components which can't be easily inferred by a screenreader. Tabs is an example. According to https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/#tabpanel the element should have specific roles, aria attributes and keyboard interactions (which isn't possible to provide without providing some sort of state helper in the lib).
I'm not sure if the library should implement it or let it to the developer. But I'd guess that in the latter situation most developers will not implement any of these a11y stuff, and that's bad for people who need it.
FYI, I've added some benchmarks comparing reas with other libs: https://github.com/diegohaz/reas#performance
@diegohaz that link doesn't go anywhere. Is there a newer link?
Most helpful comment
Definitely intrigued by this library, but I'll chime in to how I see these as being different concepts.
Button.extendThis is probably the thing I understand least about reas (and am most curious about) โ I don't understand what it does nor why I would want this. Would love to see some more documentation and explanation for the rationale here in the docs. I'm planning on taking a look later, so forgive my ignorance.
For Rebass, I've preferred to keep things a little more React-like by using props. If you want to change the underlying element, you can do things like this:
This is correct, but architecturally I don't think it makes sense to keep state in low-level UI components like Rebass. For applications, I try to make good use of React's functional setState and have a small library that wraps some of that sort of thing up here: https://github.com/jxnblk/refunk
I'm not sure I understand what reas does to be WAI-ARIA compliant by default โ I think there's a lot of general misunderstanding about accessibility in the field and want to clarify that it's not really feasible to have accessibility features built in to Rebass beyond what it does now. Rebass uses semantic HTML elements where appropriate, so there's no need for aria attributes (when you use the Input for forms for example), but you do need to handle accessibility on your end, just as with any other HTML you may write. E.g. if you have an
<img>tag, you need analtattribute, and with Rebass, you should usealtattributes on theImagecomponent.Anyway, hope that's helpful, and I'm curious to see where you go with this library