Descripción general de Web Components Chip

    Ignite UI for Web Components Chips ayudan a las personas a ingresar información, hacer selecciones, filtrar contenido o activar acciones.

    Web Components Chip Example

    EXAMPLE
    TS
    HTML
    CSS

    Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.

    Usage

    En primer lugar, debe instalar el Ignite UI for Web Components ejecutando el siguiente comando:

    npm install igniteui-webcomponents
    cmd

    Luego necesitarás importar IgcChipComponent, su CSS necesario y registrar su módulo, así:

    import { defineComponents, IgcChipComponent } from 'igniteui-webcomponents';
    import 'igniteui-webcomponents/themes/light/bootstrap.css';
    
    defineComponents(IgcChipComponent);
    ts

    Para obtener una introducción completa a Ignite UI for Web Components, lea el tema Primeros pasos.

    La forma más sencilla de empezar a utilizarlo IgcChipComponent es la siguiente:

    <igc-chip></igc-chip>
    html

    Para mostrar un chip seleccionable, puede utilizar la propiedad selectable del chip.

    <igc-chip selectable></igc-chip>
    html

    Para mostrar un chip extraíble, puede utilizar la propiedad removable del chip.

    <igc-chip removable></igc-chip>
    html
    Ignite UI for Web Components | CTA Banner

    Examples

    Variants

    El chip Ignite UI for Web Components admite varias variantes estilísticas predefinidas. Puede cambiar la variante asignando uno de los valores admitidos -Primary, Info, Success, Warning, o Danger a la variant propiedad.

    <igc-chip variant="success"></igc-chip>
    html

    EXAMPLE
    TS
    HTML
    CSS

    Disabled

    El chip Ignite UI for Web Components se puede deshabilitar mediante la disabled propiedad.

    <igc-chip disabled></igc-chip>
    html

    Prefix / Suffix

    Con las partes Prefix y Suffix del componente IgcChipComponent y sus ranuras, podemos agregar contenido diferente antes y después del contenido principal del chip. Proporcionamos íconos predeterminados para seleccionar y eliminar, pero puede personalizarlos usando las ranuras IgcSelectComponent y Remove. Puede agregar contenido adicional antes o después del contenido principal, utilizando las ranuras Start y End.

    <igc-chip selectable removable>
      <span slot="select"><igc-icon name="verified-account"></igc-icon></span>
      <span slot="start"><igc-icon name="brush"></igc-icon></span>
        Chip
      <span slot="end"><igc-icon name="blood"></igc-icon></span>
      <span slot="remove"><igc-icon name="pacifier"></igc-icon></span>
    </igc-chip>
    html

    EXAMPLE
    TS
    HTML
    CSS

    Tamaño

    Permitimos que el usuario elija el tamaño del IgcChipComponent utilizando la variable CSS--ig-size:

    igc-chip {
      --ig-size: var(--ig-size-large);
    }
    css

    EXAMPLE
    TS
    HTML
    ChipSize.css
    index.css

    Styling

    El IgcChipComponent componente expone partes base​ ​prefix​ ​suffix CSS que se pueden utilizar para cambiar todas sus propiedades de estilo.

    igc-chip::part(base) {
      background: var(--ig-primary-500);
      color: var(--ig-primary-500-contrast);
    }
    
    igc-chip::part(suffix) {
      color: var(--ig-gray-400);
    }
    css

    EXAMPLE
    TS
    HTML
    ChipStyle.css
    index.css

    API References

    Additional Resources