GUILD OF GLEKS UIv21.4.4

gog-button  ·  [gogButton]

Button

A debounced action button with four variants, five sizes, and built-in loading, disabled, and full-width states — plus, since 21.4.0, a [gogButton] directive that gives the same look to a link you own.

Overview

Import the component and drop it into a template.

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

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

Basic usage — a primary button that reacts to a click:

<gog-button variant="primary" (gogClick)="onClick($event)">
  Click me
</gog-button>

Examples

Variants & sizes

Every combination of the four variants and five sizes.

primary
secondary
outline
ghost
<gog-button variant="primary" size="md">Primary</gog-button>
<gog-button variant="secondary" size="md">Secondary</gog-button>
<gog-button variant="outline" size="md">Outline</gog-button>
<gog-button variant="ghost" size="md">Ghost</gog-button>

Disabled

One disabled button per variant — disabled state must stay legible on every color.

<gog-button variant="primary" [disabled]="true">Primary</gog-button>

Loading

Loading swaps the label for a spinner and blocks clicks (via aria-disabled, not the native disabled attribute, so focus is preserved).

The spinner scales with the button size:

<gog-button
  variant="primary"
  [loading]="isLoading()"
  (gogClick)="simulateLoading()"
>
  Simulate loading
</gog-button>

Full width

Stretches to fill its container; wrapped here in a narrower box to show it.

<gog-button variant="outline" [fullWidth]="true">Full width</gog-button>

Icon-only

No visible label, so ariaLabel is required — it targets the inner <button>, unlike a plain aria-label attribute on <gog-button> itself.

<gog-button variant="primary" ariaLabel="Confirm">
  <gog-icon name="check" />
</gog-button>

Debounce guard

Clicks are throttled leading-edge: the first click fires immediately, further clicks are dropped for debounce ms (default 300). Click rapidly and watch the counter lag behind your clicks.

Accepted clicks: 0

<gog-button variant="primary" [debounce]="300" (gogClick)="onSpamClick()">Click me fast</gog-button>

Native type semantics

type is forwarded to the native <button>.

Neither button pressed yet.

<form (submit)="onFormSubmit($event)" (reset)="onFormReset()">
  <gog-button variant="primary" type="submit">Submit</gog-button>
  <gog-button variant="outline" type="reset">Reset</gog-button>
</form>

gog-button renders its own <button>, so it can never be a link. The directive inverts that: the element stays yours and [gogButton] only gives it the look.

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

@Component({
  // ...
  imports: [GogButtonDirective],
})
<a gogButton routerLink="/general/theming">See theming</a>
<a gogButton variant="ghost" href="https://example.com" target="_blank" rel="noreferrer">
  Docs
</a>
<button gogButton variant="outline" size="sm" type="submit">Save</button>
<a gogButton fullWidth routerLink="/components/table">Checkout</a>

The selector is a[gogButton], button[gogButton] — deliberately not a bare [gogButton]. On a <div> the result would look like a button while being invisible to the keyboard and to assistive technology.

Which one to reach for

The component when the button acts on the page: it owns loading (a centred spinner it projects), debounce click throttling and the gogClick output — none of which a bare element can provide. The directive when the element must be a link, or must keep directives of its own. routerLink, href, target, download, type="submit" and the rest keep working because they were never brokered through an input in the first place.

That is also why the library still has no @angular/router dependency — a design point, not an omission. A component that took a routerLink input would force the router on every app that installs the package.

Two things the directive deliberately does not do: no disabled on an <a> (there is no such thing — drop the href or render a real <button>), and no loading state (the spinner is a projected child, which a directive cannot add without taking over the element's content).

Its styles live in the global styles/button.css, pulled in by index.css, because Angular's emulated encapsulation could never reach an element declared in your template. Nothing changes in your setup — see Theming.

[gogButton] — Inputs

NameTypeDefaultDescription
variant'primary' | 'secondary' | 'outline' | 'ghost''primary'Visual style — the same four the component offers.
size'xsm' | 'sm' | 'md' | 'lg' | 'slg''md'Also settable app-wide via GOG_CONFIG.control.size.
fullWidthbooleanfalseStretches the element to fill its container. A bare attribute works.

API Reference

Inputs

NameTypeDefaultDescription
variant'primary' | 'secondary' | 'outline' | 'ghost''primary'Visual style of the button.
size'xsm' | 'sm' | 'md' | 'lg' | 'slg''md'Button size.
disabledbooleanfalseFully non-interactive: excluded from tab order via the native disabled attribute.
fullWidthbooleanfalseStretches the button to fill its container.
type'button' | 'submit' | 'reset''button'Forwarded to the native <button> type attribute.
loadingbooleanfalseShows a spinner in place of the label and blocks activation. Uses aria-disabled rather than the native disabled attribute, so the button stays focusable.
debouncenumber300Minimum time, in ms, between accepted clicks. Leading-edge throttle: the first click fires immediately, further clicks are dropped until the window elapses.
ariaLabelstring | nullnullAccessible name forwarded to the native <button>. Required for icon-only buttons — a plain aria-label attribute on <gog-button> lands on the host element, not the inner button, so assistive tech never sees it.

Outputs

NameTypeDescription
gogClickEventEmitter<MouseEvent>Emitted on each accepted click, after debounce throttling.

Styling Tokens

Every CSS custom property the button 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-btn-font-family / -font-weight / -letter-spacing / -text-transformLabel typography.
--gog-btn-radiusCorner radius.
--gog-btn-border-width / -styleBorder.
--gog-btn-transition-durationHover / active transition timing.
--gog-btn-{variant}-bg / -color / -border / -shadowFill, text, border and shadow per variant (primary/secondary/outline/ghost).
--gog-btn-{variant}-hover-bg / -hover-color / -hover-shadowHover state per variant.
--gog-btn-bg / -color / -border / -padding / -font-sizeUndeclared by default — the escape hatch for styling a single button instance.