Current version 22.2.0

Migrating from tgButton2

Replace the tgButton2 attribute with tg2Button, and import Tg2ButtonComponent instead of TgButton2Component.

Selector

Before

After

<!-- Before -->
<button tgButton2>Button</button>

<!-- After -->
<button tg2Button>Button</button>

Variant

The separate inputs ([transparent], [tgStyle]) are replaced by a single tg2Style input. Primary is the default and can be omitted.

Before

After

<!-- Before -->
<button tgButton2 [transparent]="true">Button</button>

<!-- After -->
<button tg2Button tg2Style="transparent">Button</button>

Size

The [compact] boolean is replaced by a size input.

Before

After

<!-- Before -->
<button tgButton2 [compact]="true">Button</button>

<!-- After -->
<button tg2Button size="small">Button</button>

Auto size

The [autoCompact] boolean is replaced by the autoSize input, which shrinks the button to the specified size on narrow viewports (≤ sm breakpoint). Use autoSize="small" to match the old behaviour.

Before

After

<!-- Before -->
<button tgButton2 [autoCompact]="true">Button</button>

<!-- After -->
<button tg2Button autoSize="small">Button</button>

Shape

The shape input replaces the old pattern of combining [transparent] and [tag] to achieve pill styling. In tgButton2, the o-transparent-button2.o-tag-button2 combination applied a border-radius — there was no standalone rounded modifier.

Before

After

<!-- Before: transparent + tag was the only way to get pill styling -->
<button tgButton2 [transparent]="true" [tag]="true">Button</button>

<!-- After -->
<button tg2Button shape="round">Button</button>

Icon only

Icon-only detection is no longer automatic. Add [iconOnly]="true" explicitly when the button contains only an icon.

Before

After

<!-- Before (icon-only detected automatically) -->
<button tgButton2 aria-label="heart">
    <tg-icon name="heart"></tg-icon>
</button>

<!-- After -->
<button tg2Button [iconOnly]="true" aria-label="heart">
    <tg-icon-left name="heart"></tg-icon-left>
</button>

Spacing

tgButton2 baked in a bottom margin for stacking (larger again on [compact]). tg2Button applies no margin of its own — add a margin-bottom if you need spacing between buttons.

  • size="large" (default): margin-bottom: $tg-spacing-compact;
  • size="medium": margin-bottom: $tg-unit;
  • size="small": margin-bottom: $tg-unit;
<!-- Before (tgButton2 applied its own margin-bottom for stacking) -->
<button tgButton2>Button one</button>
<button tgButton2>Button two</button>

<!-- After (tg2Button applies no margin — add it explicitly) -->
<button tg2Button class="my-button-spacing">Button one</button>
<button tg2Button class="my-button-spacing">Button two</button>

// my-button-spacing.scss
.my-button-spacing {
    margin-bottom: $tg-spacing-compact; // large (default) — use $tg-unit for medium/small
}
Proudly made by © 2026 Trade Me Limited