Skip to content

Tag's icon prop renders a string literally instead of as an icon (Button already handles this) #220

Description

@einari

Tag's icon prop does not accept a PrimeIcons class-name string the way Button's does — passing one renders it as literal text instead of an icon.

Expected

Button (Common/Button.js) has a renderIcon helper:

const renderIcon = (icon) => typeof icon === 'string' ? jsx("i", { className: icon, "aria-hidden": 'true' }) : icon;

so <Button icon='pi pi-user' /> renders a proper <i className="pi pi-user"> icon. Tag's own JSDoc says it exists specifically to restore the PrimeReact-10-era authoring ergonomics on top of PrimeReact 11, matching Button's stated purpose.

Actual

Tag (Display/Tag.js) passes icon straight through as a child with no conversion:

const Tag = ({ value, severity, rounded, icon, className, children }) => (jsxs(Tag$1, { severity, rounded, className, "data-severity": severity, children: [icon, value ?? children] }));

<Tag value="Member" severity="success" icon="pi pi-user" /> renders the literal text pi pi-userMember — the icon class name is printed as a text node instead of becoming an icon.

Repro

import { Tag } from '@cratis/components/Display';

<Tag value="Member" severity="success" icon="pi pi-user" />

Expected: a green pill with a person icon followed by "Member".
Actual: a green pill containing the literal text "pi pi-userMember".

Why it matters

Every call site written against Tag's documented authoring model (a plain PrimeIcons class-name string, matching Button's) silently breaks in this exact way — no type error, no console warning, since icon?: React.ReactNode accepts a string just fine. Only a live render exposes it. Badge (Display/Badge.js) has the identical icon-less-conversion shape as Tag (no icon prop at all there, so not directly affected, but worth checking for the same class of gap if one is ever added).

Version: @cratis/components@3.5.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions