Refactor Button Component to Use Icon Component

Created on 14 May 2025, 5 months ago

Problem/Motivation

The current button component uses an inline {{ icon(...) }} function in its Twig template to render icons. This hardcodes the icon rendering logic directly into the template, reducing flexibility and making maintenance more challenging. For example, any updates to the icon component require manually modifying each instance in the button template.

Proposed resolution

Refactor the button component to use a slot for the icon instead of embedding the {{ icon(...) }} function. This will allow users to pass in the icon component or any other content dynamically via a slot, improving modularity and reusability.

Remaining tasks

  • Update button.component.yml: Add a slot definition for the icon.
  • Modify button.twig and make the slot optional so the button remains functional without an icon.
  • Update the documentation to reflect the new slot-based approach.

User interface changes

Icons will be rendered via the slot, ensuring consistency and flexibility.

Data model changes

No changes to the underlying data structure; this refactoring only affects the rendering logic.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium raluelrusu Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024