Skip to content

View component x-icon defaults to 1em x 1em and doesn't include method to override this #1955

@iamdadmin

Description

@iamdadmin

Tempest version

3.x

PHP version

8.5

Operating system

Linux

Description

Reference: https://iconify.design/docs/usage/svg/no-code/

By default the Iconify API returns a SVG with height and width attributes set to 1em.

The tempest/icon class doesn't currently expose a prop to override this.

The tempest/view x-icon component does add a $class prop, but does not override the width and height attributes.

I've found this to be incompatible with tailwind height and width utilities in the class string, instead defaulting to the width and height attributes. That could be a precedence or browser rendering issue, but nonetheless highlights the default behaviour is fixed and not developer-controllable.

Steps to reproduce

Use <x-icon to render any icon and you will see the returned HTML includes the width and height attributes

Possible fixes

  1. Add ?height=none to the download url in icon.config.php and allow the <x-icon class attribute defined by the developer to control height and width, with perhaps a default of 1em applied here for easy control.
  2. Add the width and height props to tempest/icon class which in turn is filled from <x-icon height="" width="" attributes. More extensive changes to tempest/icon and possibly not proportionate given the simplicity of option 1 and little added benefit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions