Chip
Chip
Component demo
Interactive example
<ic-chiplabel="Americano"dismissible="true"id='my-chip'><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip><ic-chiplabel="Cappuccino"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip>
<IcChiplabel="Americano"dismissibleonIcDismiss={(ev)=>console.log(ev)}><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip><IcChiplabel="Cappuccino"><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip>
Chip details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The text rendered within the chip. |
|
|
The custom chip colour. This will override the theme colour. Can be a hex value e.g. "#ff0000", RGB e.g. "rgb(255, 0, 0)", or RGBA e.g. "rgba(255, 0, 0, 1)". |
|
|
If |
|
|
If |
|
|
The size of the chip. |
|
|
Sets the chip to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. Setting the "customColor" prop will override this. |
|
|
If |
|
|
The emphasis of the chip. |
|
The text rendered within the chip. |
The custom chip colour. This will override the theme colour. Can be a hex value e.g. "#ff0000", RGB e.g. "rgb(255, 0, 0)", or RGBA e.g. "rgba(255, 0, 0, 1)". |
If |
If |
The size of the chip. |
Sets the chip to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. Setting the "customColor" prop will override this. |
If |
The emphasis of the chip. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
Outline
Interactive example
<ic-chiplabel="Americano"variant="outlined"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg></ic-chip>
<IcChiplabel="Americano"variant="outlined"><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></SlottedSVG></IcChip>
Dismissible
Interactive example
<ic-chiplabel="Americano"dismissible="true"id='my-chip'><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip><script> const chip = document.querySelector('#my-chip'); chip.addEventListener('icDismiss', (ev) => console.log(ev));</script>
<IcChiplabel="Americano"dismissibleonIcDismiss={(ev)=>console.log(ev)}><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip>
Disabled
Interactive example
<ic-chiplabel="Americano"dismissible="true"disabled="true"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip><ic-chiplabel="Americano"variant="outlined"dismissible="true"disabled="true"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg></ic-chip>
<IcChiplabel="Americano"dismissibledisabled><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip><IcChiplabel="Americano"variant="outlined"dismissibledisabled><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></SlottedSVG></IcChip>
Theme
Interactive example
<ic-chiplabel="Americano"dismissible="true"id='my-chip'theme="dark"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip><ic-chiplabel="Cappuccino"><svgslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></svg></ic-chip>
<IcChiplabel="Americano"dismissibletheme="dark"><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip><IcChiplabel="Cappuccino"><SlottedSVGslot="icon"viewBox="0 0 24 24"fill="currentColor"xmlns="http://www.w3.org/2000/svg"aria-label="coffee"><pathd="M2,21V19H20V21H2M20,8V5H18V8H20M20,3A2,2 0 0,1 22,5V8A2,2 0 0,1 20,10H18V13A4,4 0 0,1 14,17H8A4,4 0 0,1 4,13V3H20M16,5H6V13A2,2 0 0,0 8,15H14A2,2 0 0,0 16,13V5Z"/></SlottedSVG></IcChip>