GUILD OF GLEKS UIv21.19.0

gog-chip

Chip

A compact, clickable label with five sizes, two shapes, and optional avatar, icon, and remove affordances.

Overview

Import the component and drop it into a template.

typescript
import { ChipComponent } from '@guildofgleks/ui';

@Component({
  // ...
  imports: [ChipComponent],
})

Basic usage — clickable chips with projected content, reporting gogClick:

Design
Research

gogClick: nothing yet

<gog-chip (gogClick)="lastClicked.set('Design')">Design</gog-chip>
<gog-chip (gogClick)="lastClicked.set('Research')">Research</gog-chip>

<p>gogClick: {{ lastClicked() }}</p>

Examples

Sizes and states

Six states at each of the five sizes, all live — hover and press are the chip's own and cannot be forced from a page. selected is tri-state: unset, the chip is a plain chip; false and true make it a toggle that is off or on, and on draws an inset ring rather than a fill, because hover and press already own the background. A disabled chip keeps its ring — "on, and unavailable right now" is a real state. [clickable]="false" is a label: no hover, no press, not a button.

size: xsm
default
off
on
disabled
disabled, on
label
size: sm
default
off
on
disabled
disabled, on
label
size: md
default
off
on
disabled
disabled, on
label
size: lg
default
off
on
disabled
disabled, on
label
size: slg
default
off
on
disabled
disabled, on
label
@for (size of sizes; track size) {
  <div>
    <span>size: {{ size }}</span>
    <gog-chip [size]="size">default</gog-chip>
    <!-- A toggle that is off: it says so with aria-pressed="false". -->
    <gog-chip [size]="size" [selected]="false">off</gog-chip>
    <gog-chip [size]="size" [selected]="true">on</gog-chip>
    <gog-chip [size]="size" disabled>disabled</gog-chip>
    <!-- On, and unavailable right now: the ring stays. -->
    <gog-chip [size]="size" [selected]="true" disabled>disabled, on</gog-chip>
    <gog-chip [size]="size" [clickable]="false">label</gog-chip>
  </div>
}

Avatar, icon and remove button

The avatar, the icon and the remove button are each a ratio of the chip's own font size, so the whole object scales from one number. avatarUrl and iconName are independent — set both and both render.

size: xsm
Ada Lovelace
Starred
Alan Turing
size: sm
Ada Lovelace
Starred
Alan Turing
size: md
Ada Lovelace
Starred
Alan Turing
size: lg
Ada Lovelace
Starred
Alan Turing
size: slg
Ada Lovelace
Starred
Alan Turing
@for (size of sizes; track size) {
  <div>
    <span>size: {{ size }}</span>
    <gog-chip [size]="size" [avatarUrl]="ada" avatarAlt="">Ada Lovelace</gog-chip>
    <gog-chip [size]="size" iconName="star">Starred</gog-chip>
    <!-- Avatar and icon are independent: set both and both render. -->
    <gog-chip
      [size]="size"
      [avatarUrl]="alan"
      avatarAlt=""
      iconName="warning"
      removable
      removeAriaLabel="Remove Alan Turing"
    >
      Alan Turing
    </gog-chip>
  </div>
}

When the picture fails 21.19.0

The avatar is a gog-avatar at the chip's own size, so a URL that fails falls back the way an avatar does: to the initials of avatarAlt, or to the person icon without one — never the browser's broken-image glyph. With no avatarAlt the avatar stays decorative, as alt="" did; with one it is named by it, as before.

Ada Lovelace
picture
Grace Hopper
fails, with avatarAlt
Guest
fails, no avatarAlt
<div>
  <gog-chip [avatarUrl]="ada" avatarAlt="Ada Lovelace">Ada Lovelace</gog-chip>
  <span>picture</span>
</div>
<div>
  <!-- An image that cannot load. On this server-rendered page it fails before the app hydrates. -->
  <gog-chip [avatarUrl]="broken" avatarAlt="Grace Hopper">Grace Hopper</gog-chip>
  <span>fails, with avatarAlt</span>
</div>
<div>
  <gog-chip [avatarUrl]="broken">Guest</gog-chip>
  <span>fails, no avatarAlt</span>
</div>

Shapes

rounded (the default) or a fully rounded pill, with and without an avatar and a remove button.

shape="rounded"
Ada Lovelace
shape="pill"
Ada Lovelace
@for (shape of shapes; track shape) {
  <gog-chip [shape]="shape">shape="{{ shape }}"</gog-chip>
  <gog-chip [shape]="shape" [avatarUrl]="ada" avatarAlt="" removable>Ada Lovelace</gog-chip>
}

Filter chips

[(selected)] turns a row of chips into toggles that need no click handler: each flips its own value on click, Enter and Space, and announces aria-pressed. gogClick still fires, after the flip, so a handler reading the value sees the new one; if the page drives the state itself from that handler, bind one-way — [selected] — or the two flips cancel out. For a choice of exactly one, this is the wrong component: use gog-button-toggle-group or a radio group.

Accessibility
Theming
Forms
Tables

selected: Accessibility, Forms

<!-- Two-way: each chip flips its own value on click, Enter and Space. -->
@for (topic of topics; track topic.label) {
  <gog-chip [(selected)]="topic.on">{{ topic.label }}</gog-chip>
}

<p>selected: {{ selectedTopics().join(', ') || 'none' }}</p>

Removable

removable adds a button that emits gogRemove; the chip does not remove itself, the list it came from does. The button works from the keyboard 21.15.0: Tab to it and press Enter or Space. Give each a removeAriaLabel that says what it removes — the default, "Remove chip", is the same for every chip in the row. These chips are [clickable]="false", since removing is their only action. A disabled chip hides its button rather than offering one that does nothing.

Angular
Design system
Pinned
Open
Disabled hides the button

last: nothing yet

<!-- The chip does not remove itself: the list it came from does. -->
@for (filter of filters(); track filter) {
  <gog-chip
    [clickable]="false"
    removable
    [removeAriaLabel]="'Remove filter ' + filter"
    (gogRemove)="remove(filter)"
  >
    {{ filter }}
  </gog-chip>
}
<gog-chip [clickable]="false" removable disabled>Disabled hides the button</gog-chip>
<gog-button variant="outline" size="sm" (gogClick)="reset()">Reset</gog-button>

<p>last: {{ lastAction() }}</p>

Full width

Off by default. On, the chip fills its container — the dashed box here — and the remove button stays at the end.

fullWidth unset
fullWidth
<gog-chip>fullWidth unset</gog-chip>
<!-- The remove button stays at the end of the stretched chip. -->
<gog-chip fullWidth removable>fullWidth</gog-chip>

App-wide defaults — GOG_CONFIG

The ripple is the only key a chip reads: ripple.enabled turns it on for every chip under the provider, and an instance's [ripple] still wins. Press each. A chip that is not clickable never ripples — a label that waves at a press promises something it will not do. In an app the provider goes in app.config.ts — see Global Configuration.

Ripple from the config
[ripple]="false" — the instance wins
Not clickable
<gog-chip>Ripple from the config</gog-chip>
<gog-chip [ripple]="false">[ripple]="false" — the instance wins</gog-chip>
<!-- A label never ripples, whatever the config says. -->
<gog-chip [clickable]="false">Not clickable</gog-chip>

Accessibility

A clickable chip is a role="button" with a tab stop; a filter chip adds aria-pressed; a label chip is plain text.

  • Name — the chip's content, or ariaLabel. A removable chip is two sibling buttons, so the chip is named by its content alone — "Angular", not "Angular Remove filter Angular" — and the remove button by removeAriaLabel.
  • Keyboard — Tab reaches the chip and then its remove button; Enter or Space presses whichever has focus.
  • State — aria-pressed while selected is true or false. false is written, not left out, because a chip with no aria-pressed is not a toggle to a screen reader at all; null writes nothing. A disabled chip drops role="button" and with it aria-pressed, though it keeps the ring on screen.
  • clickable is on by default, so every chip is a button and a tab stop unless it says otherwise. A chip that only shows a value should set [clickable]="false", or a keyboard user tabs through buttons that do nothing. For a coloured status label, gog-tag is the component.

API Reference

Inputs

NameTypeDefaultDescription
size'xsm' | 'sm' | 'md' | 'lg' | 'slg''md'Font size, padding, gap, and avatar/icon size.
shape'rounded' | 'pill''rounded'Corner radius style.
disabledbooleanfalseBlocks click/keyboard activation and hides the remove button, regardless of removable.
clickablebooleantrueWhether the chip responds to click/Enter/Space and exposes role="button". Set false for a static, non-interactive label.
selectedboolean | nullnullTwo-way. Makes the chip a filter chip: one you toggle rather than press. null is not a toggle at all and is the default, so an existing chip is untouched; false is a toggle that is off and says so with aria-pressed="false"; true is on and draws an inset ring. The chip flips it itself on click, Enter and Space.
removablebooleanfalseShows a trailing remove (×) button that emits gogRemove.
fullWidthbooleanfalseStretches the chip to fill its container.
ariaLabelstring''Accessible name for the chip surface.
removeAriaLabelstring'Remove chip'Accessible name for the remove button.
avatarUrlstring | nullnullLeading avatar image, drawn by a gog-avatar at the chip’s own size (since 21.19.0). A URL that fails falls back to the initials of avatarAlt, or to the person icon.
avatarAltstring''Names the avatar, and gives the initials it falls back to. Empty, the avatar is decorative.
iconNameGogIconName | nullnullLeading icon. Renders independently of avatarUrl — if both are set, the avatar and icon both render.
rippleboolean | undefinedundefinedPress ripple on the chip surface. Unset, falls back to GOG_CONFIG.ripple.enabled, which is off by default; setting it here wins over the app-wide value in both directions.

Outputs

NamePayloadDescription
gogClickMouseEvent | KeyboardEventEmitted on click, Enter, or Space, when clickable and not disabled — after the flip, for a filter chip.
gogRemovevoidEmitted when the remove button is pressed. Stops the click from also reaching gogClick.
selectedChangeboolean | nullThe flipped value of a filter chip. Comes from the selected model input.

Global Configuration

Set any of these once with provideGogConfig() instead of repeating them on every instance — an instance's own input still wins when it sets one itself. See Global Configuration for the full reference.

  • GOG_CONFIG.ripple.enabled

This site is not on the default here. The library ships ripple.enabled as false; these docs set it to true app-wide so the demos above actually show the press feedback. In a fresh app you get no ripple until you ask for one — the droplet button in the header switches this site between the two, and it is on right now.

Styling Tokens

Every CSS custom property the chip paints with. Override any of them — on a single instance, a subtree, or a theme — to restyle it. See the Theming guide for the full token-layering model, or the Theme Generator to tweak these live.

TokenDescription
--gog-chip-bg / -hover-bg / -press-bgBackground, default, hover and pressed.
--gog-chip-selected-shadow / -selected-ring-widthThe inset ring a filter chip draws while selected ([(selected)], 21.9.0). A ring rather than a fill, because hover and press already own the background.
--gog-chip-border / -border-width / -styleBorder. Since 21.12.0 the colour defaults to --gog-control-boundary-color rather than the decorative --gog-border-color: a chip is a control, and its edge is what identifies it. That is why chips look outlined more firmly than they did — they were at 1.18:1 in primeng before.
--gog-chip-focus-ring-color / -width / -offsetThe keyboard focus ring. The colour is new in 21.12.0 — the chip had a width and an offset but no colour of its own, so the stylesheet reached for --gog-chip-border and the ring came out as a hairline. A focus indicator needs its own colour.
--gog-chip-color / -font-weightText color and weight.
--gog-chip-radius / -pill-radiusCorner radius, square and pill shape.
--gog-chip-remove-color / -remove-hover-colorRemove (×) icon color.
--gog-chip-{size}-font-size / -padding-block / -padding-inline / -gap / -avatar-size / -icon-size / -remove-sizeFull sizing scale, per size step (xsm/sm/md/lg/slg). The three glyph sizes are ratios of the chip’s own type rather than px ladders since 21.11.0 — avatar 1.5em, icon 1em, remove mark 1.125em, one value at every size — so overriding a size’s font-size carries its glyphs with it, which the rem ladder did not.