Button

The button component is used for navigating and triggering actions. A button holds text, an icon or a combination of both. When using an icon only, it needs to be self-explanatory.

´ Loading interactive demo...
<button dt-button>Simple button</button> <a href="#" dt-button>Simple anchor button</a> export class DefaultButtonExampleComponent { } Simple anchor button export class DefaultButtonExampleComponent { }

Button variants

Compared to the secondary button, the primary button is more dominant and will attract the users attention with ease. This can be used to guide the user and help him perform the right actions. The secondary button is used for secondary actions.

Primary and secondary

´ Loading interactive demo...
<button dt-button>Primary button</button> <button dt-button variant="secondary">Secondary button</button> export class VariantButtonExampleComponent {} export class VariantButtonExampleComponent {}

Primary and secondary with icon

´ Loading interactive demo...
<p> <button dt-button><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p><p> <button dt-button color="warning"><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button color="warning" variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p><p> <button dt-button color="cta"><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button color="cta" variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p> export class IconsButtonExampleComponent {}

export class IconsButtonExampleComponent {}

Icon only

´ Loading interactive demo...
<button dt-icon-button><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="nested"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning" variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning" variant="nested"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta" variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta" variant="nested"><dt-icon name="agent"></dt-icon></button> export class IconOnlyButtonExampleComponent {} export class IconOnlyButtonExampleComponent {}

Nested buttons are a variant of icon-only buttons and can't be used with text. These buttons are only used within other components (e.g. input fields, tables,...)

Colored buttons

The button component is themable and colored differently in the context of:

  • primary: Default button, see above.
  • a warning: Only use this kind of button where a user action is needed to get something back up and running. E.g. Restart processes, update agent,...
  • a call to action: Only use this kind of button to encourage users to buy our product. E.g. install an agent, install security gateway, upgrade web check,...
´ Loading interactive demo...
<button dt-button>Button in main color</button> <button dt-button color="warning">Button in warning color</button> <button dt-button color="cta">Button in cta color</button> export class ColorButtonExampleComponent { } export class ColorButtonExampleComponent { }

Buttons on dark background

All button variants can also be put on a dark background.

´ Loading interactive demo...
<section class="dark" dtTheme=":dark"> <div class="variant"> <h4>Primary Button</h4> <p> <button dt-button>Default Button</button> <button dt-button color="warning">Warning Button</button> <button dt-button color="cta">CTA Button</button> </p><p> <button dt-button><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button color="warning"><dt-icon name="agent"></dt-icon>Warning with icon</button> <button dt-button color="cta"><dt-icon name="agent"></dt-icon>CTA with icon</button> </p><p> <button dt-icon-button><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta"><dt-icon name="agent"></dt-icon></button> </p> </div> <div class="variant"> <h4>Secondary Button</h4> <p> <button dt-button variant="secondary">Secondary Button</button> <button dt-button variant="secondary" color="warning">Secondary Warning Button</button> <button dt-button variant="secondary" color="cta">Secondary CTA Button</button> </p><p> <button dt-button variant="secondary"><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button variant="secondary" color="warning"><dt-icon name="agent"></dt-icon>Warning with icon</button> <button dt-button variant="secondary" color="cta"><dt-icon name="agent"></dt-icon>CTA with icon</button> </p><p> <button dt-icon-button variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary" color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary" color="cta"><dt-icon name="agent"></dt-icon></button> </p> </div> <div class="variant"> <h4>Nested Button</h4> <button dt-icon-button variant="nested"><dt-icon name="agent"></dt-icon></button> </div> <div class="variant"> <h4>Disabled Button</h4> <p> <button dt-button disabled>Disabled Button</button> <button dt-button disabled variant="secondary">Disabled Secondary Button</button> </p><p> <button dt-button disabled><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button disabled variant="secondary"><dt-icon name="agent"></dt-icon>Warning with icon</button> </p><p> <button dt-icon-button disabled><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="nested"><dt-icon name="agent"></dt-icon></button> </p> </div> </section> export class DarkButtonExampleComponent { }

Primary Button

Secondary Button

Nested Button

Disabled Button

export class DarkButtonExampleComponent { }

Buttons margin and padding

Buttons margin and padding
x: 8px
y: 16px

Animation

The button component is not animated at all.

Behavior and corner cases

Button with a lot of text

The button width is based on the text it holds. While being as short as possible, the text should clearly describe a button's action.

Multiple buttons

Buttons beside each other
x: 8px
Buttons underneath each other
x: 8px

Combination with other components

Buttons in tables

Use secondary buttons within tables.

Buttons in tables
x: 24px
Buttons in tables
x: 24px

Buttons in forms

Buttons in forms

Buttons with text

The alignment of buttons depends on the context.

Buttons in context menus

View the context dialog styleguide.

Buttons in call to action cards

View the call to action styleguide.

Copy to clipboard

Buttons can be used in combination with an input field or a text area for the copy to clipboard functionality. This is a simple and user-friendly way to copy text or some code with a single click.

Copy to clipboard green boarder style
border: 1px solid $green-500

Please always use the checkmark icon for the green copied-button.

The text is preselected and the green 'copied' state (checkmark) turns automatically to 'Copy' after a timeframe of 800 ms or a page refresh.

Textarea

The button is always aligned on the bottom right of a text area.

Dropdown copy to clipboard open Dropdown copy to clipboard open

Appearance in a dropdown

Step 1

Dropdown copy to clipboard open

Step 2

Dropdown copy to clipboard copied

Step 3

Dropdown copy to clipboard closed

Button

´ Loading interactive demo...
<button dt-button>Simple button</button> <a href="#" dt-button>Simple anchor button</a> export class DefaultButtonExampleComponent { } Simple anchor button export class DefaultButtonExampleComponent { }

This Angular button enhances native <button> and <a> elements with Dynatrace styling. Make sure to always use <button> or <a> tags to provide the accessible experience for the user. A <button> element should be used whenever some action is performed. An <a> element should be used whenever the user will navigate to another view.

Imports

You have to import the DtButtonModule when you want to use the dt-button:


@NgModule({
  imports: [
    DtButtonModule,
  ],
})
class MyModule {}

Initialization

To apply the dynatrace button, add one of the following attributes to the <button> and <a> elements:

Attribute Description
dt-button Regular button, with text and an optional icon
dt-icon-button Icon only button, no text allowed

Options & Properties

Name Type Default Description
disabled boolean | undefined undefined Sets disable state if property is set and the value is truthy or undefined
color string | undefined main Sets color. Possible options:
  • main (default)
  • warning
  • cta
variant string | undefined primary Sets variant. Possible options:
  • primary (default)
  • secondary
  • nested Only available for dt-icon-button

Theming

The button styling depends on the theme the component is in. You can set a theme on an area of the app by using the dtTheme directive.

Example:


<div dtTheme="purple:dark">
  <button dt-button>My themed button</button>
</div>

NOTE: Right now only setting the light or dark mode is available. Full theming functionality will be added in a later stage.

Accessibility

By using native <button> or <a> elements accessibility is ensured per default. Buttons or links containing only icons (dt-icon-button) should be given a meaningful label via aria-label or aria-labelledby.

Examples

Interaction

´ Loading interactive demo...
<button dt-button (click)="counter = counter + 1 ">Increase Counter</button> <p>Counter: {{counter}}</p> export class InteractionButtonExampleComponent { counter = 0; }

Counter: {{counter}}

export class InteractionButtonExampleComponent { counter = 0; }

Variants

´ Loading interactive demo...
<button dt-button>Primary button</button> <button dt-button variant="secondary">Secondary button</button> export class VariantButtonExampleComponent {} export class VariantButtonExampleComponent {}

Colors

´ Loading interactive demo...
<button dt-button>Button in main color</button> <button dt-button color="warning">Button in warning color</button> <button dt-button color="cta">Button in cta color</button> export class ColorButtonExampleComponent { } export class ColorButtonExampleComponent { }

With Icons

´ Loading interactive demo...
<p> <button dt-button><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p><p> <button dt-button color="warning"><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button color="warning" variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p><p> <button dt-button color="cta"><dt-icon name="agent"></dt-icon>Primary with icon</button> <button dt-button color="cta" variant="secondary"><dt-icon name="agent"></dt-icon>Secondary with icon</button> </p> export class IconsButtonExampleComponent {}

export class IconsButtonExampleComponent {}

With loading spinner

The loading spinner button can only be used within a disabled button.

´ Loading interactive demo...
<button dt-button disabled><dt-loading-spinner></dt-loading-spinner>Waiting for response</button> <button dt-button disabled variant="secondary"><dt-loading-spinner></dt-loading-spinner>Waiting for response</button> export class LoadingSpinnerButtonExampleComponent {} export class LoadingSpinnerButtonExampleComponent {}

Icon only

´ Loading interactive demo...
<button dt-icon-button><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="nested"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning" variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning" variant="nested"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta" variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta" variant="nested"><dt-icon name="agent"></dt-icon></button> export class IconOnlyButtonExampleComponent {} export class IconOnlyButtonExampleComponent {}

Disabled example

´ Loading interactive demo...
<p> <button dt-button disabled>Disabled Button</button> <button dt-button disabled variant="secondary">Disabled Secondary Button</button> </p><p> <button dt-button disabled><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button disabled variant="secondary"><dt-icon name="agent"></dt-icon>Warning with icon</button> </p><p> <button dt-icon-button disabled><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="nested"><dt-icon name="agent"></dt-icon></button> </p> export class DisabledButtonExampleComponent { }

export class DisabledButtonExampleComponent { }

Dark

´ Loading interactive demo...
<section class="dark" dtTheme=":dark"> <div class="variant"> <h4>Primary Button</h4> <p> <button dt-button>Default Button</button> <button dt-button color="warning">Warning Button</button> <button dt-button color="cta">CTA Button</button> </p><p> <button dt-button><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button color="warning"><dt-icon name="agent"></dt-icon>Warning with icon</button> <button dt-button color="cta"><dt-icon name="agent"></dt-icon>CTA with icon</button> </p><p> <button dt-icon-button><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button color="cta"><dt-icon name="agent"></dt-icon></button> </p> </div> <div class="variant"> <h4>Secondary Button</h4> <p> <button dt-button variant="secondary">Secondary Button</button> <button dt-button variant="secondary" color="warning">Secondary Warning Button</button> <button dt-button variant="secondary" color="cta">Secondary CTA Button</button> </p><p> <button dt-button variant="secondary"><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button variant="secondary" color="warning"><dt-icon name="agent"></dt-icon>Warning with icon</button> <button dt-button variant="secondary" color="cta"><dt-icon name="agent"></dt-icon>CTA with icon</button> </p><p> <button dt-icon-button variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary" color="warning"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button variant="secondary" color="cta"><dt-icon name="agent"></dt-icon></button> </p> </div> <div class="variant"> <h4>Nested Button</h4> <button dt-icon-button variant="nested"><dt-icon name="agent"></dt-icon></button> </div> <div class="variant"> <h4>Disabled Button</h4> <p> <button dt-button disabled>Disabled Button</button> <button dt-button disabled variant="secondary">Disabled Secondary Button</button> </p><p> <button dt-button disabled><dt-icon name="agent"></dt-icon>Default with icon</button> <button dt-button disabled variant="secondary"><dt-icon name="agent"></dt-icon>Warning with icon</button> </p><p> <button dt-icon-button disabled><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="secondary"><dt-icon name="agent"></dt-icon></button> <button dt-icon-button disabled variant="nested"><dt-icon name="agent"></dt-icon></button> </p> </div> </section> export class DarkButtonExampleComponent { }

Primary Button

Secondary Button

Nested Button

Disabled Button

export class DarkButtonExampleComponent { }