Skip to content

[Improvement]: Add development warning for icon-only Buttons missing accessible labels #1810

@Kalpana-chavhan

Description

@Kalpana-chavhan

Description

In the current Button component, it is possible to implement icon-only buttons (or square buttons) without providing an aria-label or aria-labelledby.

Example of inaccessible code currently allowed:

<Button icon="edit" />
<Button square><Icon name="plus" /></Button>

This results in screen readers announcing only the word "button," which violates WCAG 2.1 (Success Criterion 4.1.2: Name, Role, Value).

Proposed Solution

Add a development-time check (process.env.NODE_ENV !== 'production') within the Button component. If the button lacks visible text and also lacks an ARIA label, a console.warn should be triggered to guide the developer.

Why this matters

Fuselage is the foundation for Rocket.Chat's UI. Ensuring accessibility at the component level prevents accessibility regressions across the entire ecosystem without introducing breaking changes to the API.

I have a local implementation ready and would like to submit a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions