Using element names instead of class names can be problematic. In some frameworks you may need to use a different element or an element that wraps another element to achieve certain functionality.
Some use generic names like "button large" as class names, but, again in my personal experience, it often causes problems. You might have other elements that need to be "large" and may need to be inside a button - but which "large" do you mean.
So to keep things predictable, I've adopted the following practices:
- Always namespace components.
- Always ensure that selectors work even if the child has a wrapper around it.
- Whenever possible use classnames instead of element names.
And to ensure I don't get tendonitis (not sure if everyone agrees with this):
- If possible provide a shorthand for at least the most used components (i.e. "col"/"col-i" for "collection"/"collection-item"
Using element names instead of class names can be problematic. In some frameworks you may need to use a different element or an element that wraps another element to achieve certain functionality.
Some use generic names like "button large" as class names, but, again in my personal experience, it often causes problems. You might have other elements that need to be "large" and may need to be inside a button - but which "large" do you mean.
So to keep things predictable, I've adopted the following practices:
- Always namespace components.
- Always ensure that selectors work even if the child has a wrapper around it.
- Whenever possible use classnames instead of element names.
And to ensure I don't get tendonitis (not sure if everyone agrees with this):
- If possible provide a shorthand for at least the most used components (i.e. "col"/"col-i" for "collection"/"collection-item"