Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Select (Remote Data, Tags): CSS Icons #563

Open
akhayyat opened this issue Jan 30, 2025 · 0 comments
Open

Advanced Select (Remote Data, Tags): CSS Icons #563

akhayyat opened this issue Jan 30, 2025 · 0 comments

Comments

@akhayyat
Copy link

Summary

When using advanced select with remote data and tags, how can I show icons using CSS classes (no IMG tag)?

Detailed Description

When using advanced select tags (inline data), I can show icons without img tags, using CSS classes. For example (using country-flag-icons package):

<option value="100" data-hs-select-option="{
            "description": "IS",
            "icon": "<img class=\"inline-block rounded-full flag:IS\">"
        }">Iceland</option>

When I try to do the same using the remote data version of advanced select (tags), I can't find a way to make it work, since the apiFieldsMap.icon field uses the provided attribute as an img src attribute. An API that returns <img class="inline-block rounded-full flag:IS"> as the value of the attribute mapped to apiFieldsMap.icon results in the following HTML (obviously broken: img.src is an img tag):

<img class="max-w-full" alt="Iceland" src="<img class="inline-block rounded-full flag:IS">">

How can I template the entire img tag in this case, or just have the API specify img.class instead of img.src?

Use Cases

Using an API, set the icon without having to specify a src URL. For example, set the icon by defining the entire img tag or being able to provide img.class instead of img.src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant