Post

Do you author web components with "required" attributes? The convention for most HTML elements is that no attributes are required. But in the context of a design system, it would be nice to require configuration for a custom element. Like a variant attribute for a badge or a button.

0 reposts3 likes

I try to design my components with no required attributes. It forces me to design for gradual and graceful enhancements where there's always a no-attribute default. It gets hard when there's more than 3 or 4 attr. in a component. The hardest is dealing with required combinations of attributes.

I didn't think too much about this until configuring the types for a web component to be used in React. When I made certain attributes required, I realized that no other elements require HTML attributes, and never provide type errors.