-
Notifications
You must be signed in to change notification settings - Fork 94
Description
Does your feature request relate to a specific USWDS component?
https://designsystem.digital.gov/components/alert/
What USWDS Version is this feature present in?
I don't know when it was introduced in, but it is present in 2.11.0
Is your feature request related to a problem? Please describe.
It is possible to not provide a heading to the Alert component, see screenshots from USWDS below. The implemented component accordingly has heading
as an optional prop that conditionally renders a heading depending on whether it is present. However, the headingLevel
prop is required regardless of whether the heading prop is provided.
This leads to situations where I need to decide and pass in an arbitrary headingLevel
prop, despite the Alert not having a heading.

Describe the solution you'd like
It should not be required to pass headingLevel
when heading
it is not present.
For stronger type enforcement, a typescript union type could be used to enforce that if heading is present then headingLevel must also be (but probably not vice versa, for backwards compatibility?). Another option would be to just make the headingLevel
prop optional (presumably throwing an error if it's not present?).
Describe alternatives you've considered
Additional context