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

feat: Support custom icons for ion-select #17248

Closed
6 of 7 tasks
cicixiaoyan opened this issue Jan 24, 2019 · 10 comments
Closed
6 of 7 tasks

feat: Support custom icons for ion-select #17248

cicixiaoyan opened this issue Jan 24, 2019 · 10 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@cicixiaoyan
Copy link

cicixiaoyan commented Jan 24, 2019

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

Developers are unable to customize the icon that is displayed with ion-select. Developers can change the color of the icon by using CSS:

ion-select::part(icon) {
  color: red;
}

But this does not allow the flexibility for developers to customize the icon used.

Ideally, developers would like a property or slot that can be used to customize the icon that is used.

@Prop() toggleIcon = chevronDown;
<ion-select [toggleIcon]="arrowDown"></ion-select>

This icon could then be styled using CSS shadow parts, as the existing implementation is today.

@ionitron-bot ionitron-bot bot added the triage label Jan 24, 2019
@bryplano bryplano added the type: feature request a new feature, enhancement, or improvement label Feb 6, 2019
@ionitron-bot ionitron-bot bot removed the triage label Feb 6, 2019
@FazioNico
Copy link

looking forward for

@fer-fullstackdev
Copy link

I need this feature right now. Please let me know when can you do this??
Thanks

@dylan-westbury
Copy link

To explain further.

Currently ion-select icon sits in the shadow-root, so there is no way of disabling or editing it.

With our use case, we use the detail on ion-items, and floating labels for ion-inputs, ion-selects, etc.

For ion-select, it looks like this because we can't disable the select-icon.

Image of select-icon

Here it is in the html of the above ion-select

html of select-icon

@fer-fullstackdev
Copy link

Hello, @dylan-westbury
Thanks for the explanation.
When can you implement this feature then?

@brandyscarney brandyscarney added the package: core @ionic/core package label Jun 5, 2019
@ionic-team ionic-team deleted a comment from gaiapuffo Jan 8, 2020
@brandyscarney brandyscarney changed the title hope change ion-select icons and placeholder color feat: change the ion-select icon and placeholder color Feb 26, 2020
@Lougnar
Copy link

Lougnar commented Apr 27, 2020

Currently we can use ::part to change the icon. but it's only supported in the last versions of safari/safari ios and not supported yet in samsung browser. (I have 6% of my users on samsung browser) https://caniuse.com/#search=%3A%3Apart

we should maybe make a pull request to add a slot element, ::slotted is more supported.

@kawazoe
Copy link

kawazoe commented Aug 18, 2020

I just noticed that this feature was added by #20605 but was then removed for the 5.1 release ( #21108 ). I too would like to be able to customize the style of the icon with an svg instead of the default border one.

@indraraj26
Copy link

Hi @liamdebeasi ,

We have searchIcon in ion-searchbar like that please add dropdownIcon where we can add svg and string from ionicon.

I tried but couldn't able to do it properly.

ion-select::part(icon) {
	display: none;
}

ion-select::part(text) {
	background-image: url(https://www.iconfinder.com/data/icons/ios-11-ui-elements-vol-1/29/25_dropdown_menu_down_arrow-512.png);
	background-position: right;
	background-repeat: no-repeat;
	background-size: 50%;
}

Playground link: https://codepen.io/indraraj26/pen/vYGPLMQ

@sean-perkins
Copy link
Contributor

Hello everyone 👋 doing some housekeeping here to get this feature request up to date. I will be updating the original poster's description to reflect my understanding of this feature request. Please let me know if that is inconsistent with your expectations or if you have additional requirements you would like to include.

The problem Ionic developers are facing is that the ion-select icon is created through CSS. Developers can change the color of this icon with the following CSS:

ion-select::part(icon) {
  color: red;
}

But they cannot customize the icon that is rendered. The ask here, is to support either a slot for developers to customize what is used as the "icon" for ion-select or allowing developers to pass through an ion-icon to be used.

Similar implementation patterns that exist for reference:

  • ion-accordion has @Prop() toggleIcon = chevronDown which allows developers to specify a different toggleIcon in their implementations.

@sean-perkins sean-perkins changed the title feat: change the ion-select icon and placeholder color feat: Support custom icons for ion-select Jul 28, 2022
@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement and removed type: feature request a new feature, enhancement, or improvement labels Aug 15, 2022
averyjohnston added a commit that referenced this issue Jun 20, 2023
Issue number: resolves #17248

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

While the `icon` shadow part allows customization of the existing toggle
icon, developers do not have a way to specify a different icon to use
entirely.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

New props `toggleIcon` and `expandedIcon` added. (Design docs are
[here](https://github.com/ionic-team/ionic-framework-design-documents/blob/main/projects/ionic-framework/components/select/0002-custom-icons.md)
and
[here](https://github.com/ionic-team/ionic-framework-design-documents/blob/main/projects/ionic-framework/components/select/0003-custom-icon-on-open.md)
respectively.)

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Docs PR: ionic-team/ionic-docs#2996
Dev build: `7.0.15-dev.11687278023.161b97d8`

---------

Co-authored-by: ionitron <[email protected]>
@averyjohnston
Copy link
Contributor

Props for customizing the icons have been added via #27648 and will be available in the next upcoming minor release of Ionic. Thank you!

@ionitron-bot
Copy link

ionitron-bot bot commented Jul 20, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jul 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests