Custom Icon for ToggleButton?

UI Components for Vue
Post Reply
henry000dev
Posts: 3
Joined: 04 Sep 2021, 09:13

20 Sep 2021, 13:38

Hi, I'd like to use a SVG image as the icon for a ToggleButton (as opposed to using PrimeIcons). Is there a way to customise it, similar to the templating in Button?

henry000dev
Posts: 3
Joined: 04 Sep 2021, 09:13

21 Sep 2021, 11:46

I ended up solving this issue by conditionally rendering Buttons.

So instead:

Code: Select all

<ToggleButton ... />
<ToggleButton ... />
<ToggleButton ... /> <!-- this third button needs custom icons -->
I am using:

Code: Select all

<Button ... />
<Button ... />
<Button ... > <!-- this third button needs custom icons -->
  <img v-if="someCondition"src="../assets/logo-1.svg"... />
  <img v-else src="../assets/logo-2.svg"... />
</Button>
There are minor UI differences using the approaches, such as border colours which require a bit of CSS touch-ups, but seem to work well for my case.

Note, initially I tried to use SelectButton - but there's an issue with tooltip, so didn't go with it (I'll post a separate question on this issue).

tugce.kucukoglu
Posts: 560
Joined: 23 Oct 2020, 09:28

16 Nov 2021, 14:07

Hi,

Tooltip doesn't have templating but as you said Button has. We would be grateful if you create a PR with the possible solution.

Regards,

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests