Skip to content

feat: Support custom icons for ion-select #17248

Closed

Description

@cicixiaoyan

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.

Activity

  1. added
    type: feature request
    on Feb 6, 2019
  2. FazioNico commented on Mar 28, 2019

    @FazioNico

    looking forward for

  3. fer-fullstackdev commented on Apr 15, 2019

    @fer-fullstackdev

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

  4. dylan-westbury commented on May 23, 2019

    @dylan-westbury

    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

  5. fer-fullstackdev commented on May 23, 2019

    @fer-fullstackdev

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

  6. deleted a comment from gaiapuffo on Jan 8, 2020
  7. changed the title [-]hope change ion-select icons and placeholder color[/-] [+]feat: change the ion-select icon and placeholder color[/+] on Feb 26, 2020
  8. Lougnar commented on Apr 27, 2020

    @Lougnar

    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.

  9. kawazoe commented on Aug 18, 2020

    @kawazoe

    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.

  10. indraraj26 commented on Sep 25, 2020

    @indraraj26

    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

  11. sean-perkins commented on Jul 28, 2022

    @sean-perkins
    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.
  12. changed the title [-]feat: change the ion-select icon and placeholder color[/-] [+]feat: Support custom icons for `ion-select`[/+] on Jul 28, 2022
  13. added
    type: feature request
    and removed
    type: feature request
    on Aug 15, 2022
  14. added a commit that references this issue on Jun 20, 2023
    95e28b6
  15. averyrousseau commented on Jun 20, 2023

    @averyrousseau
    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!

  16. ionitron-bot commented on Jul 20, 2023

    @ionitron-bot

    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.

  17. locked and limited conversation to collaborators on Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: coretype: feature request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions