Soracom

Design System
  1. Home
  2. Design system
  3. Elements
  4. Buttons

Buttons

Options

Basic usage

There are 3x basic button styles, ds-button, ds-button --primary and ds-button --plain, which can be applied to either <button> or <a> elements.

The primary button should be used once per component to indicate the most important or primary action. For example in a dialog that has two actions ‘Update’ and ‘Cancel’, it’s likely that ‘Update’ is the primary action and therefore should use the primary button style.

html
Copy

Using <a> elements

In addition to standard html buttons, a elements can be presented visually as buttons with the same options. See When to use a button vs a text link

html
Copy

When applying button styles to anchor links <a>, the disabled state is displayed when there is no href attribute, or by adding the class --disabled.

html
Copy

Visual states

All 3x buttons styles (default, primary and plain) adhere to 4x preset visual states - alert, warning, success and info.

Example using default style

html
Copy

Example using primary style

html
Copy

Example using plain style

html
Copy

Component colors

html
Copy

Icons

Add an additional class such as --icon-online from the available icon modifier list. Alternatively you can use an inline icon.

html
Copy

Icon position

Adding the class --right-icon will show the button on the right of the button.

Example showing right aligned icons

html
Copy

Inline icons

Alternatively ds-icon can be used inside ds-button if necessary. This can be used when more than one icon is required, or if more control over the icon is required.

html
Copy

Inline icon animation

Using inline icons allows you to use all the icon animation options. To animate the entire button, or animate a button not using inline icons see Animation below.

html
Copy

Inline icon colors

Using inline icons allows applying color to just the icon.

html
Copy

Inline icon size

Using inline icons allows you to vary the size of the icon

html
Copy

Size

xxsmall, xsmall, small, default, large

html
Copy

Buttons sizes with icons

html
Copy

Buttons sizes with icons, hide label

html
Copy

mid, wide

By default, ds-button will be a minimum of 40px wide. --mid has a minimum width of 80px, and --wide has a minimum width of 160px;

html
Copy

Hiding the label

By default a button shows the label text (the contents inside the span). This can be hidden using the --hide-label option. For accessibility purposes it’s preferable to have a descriptive label hidden using this method, rather than omitting the label text.

html
Copy

Tip Position

By adding the appropriate --tip-* class, the position of the tip can be changed.

html
Copy

The following positions are available - (hover over labels to view examples):

--tip-top-left
--tip-top
--tip-top-right
--tip-left-top
--tip-right-top
--tip-left
default (top)
--tip-right
--tip-left-bottom
--tip-right-bottom
--tip-bottom-left
--tip-bottom
--tip-bottom-right

Animation

Animation states for buttons should only be used sparingly to indicate temporary states (such as uploading/downloading a file, sending/receiving data or waiting for a server side process to complete).

--spin works with any icon on the available icon modifier list. This option will animate the icon in-place (and requires an existing --icon-* class to exist on the button).

Also see Inline icon animation for examples of other animations that can be applied to an inline icon.

--spin

html
Copy

--pulse

html
Copy

--glow

html
Copy

--blink

html
Copy

--spin and --pulse

html
Copy

Loading state

A button can be triggered to display a loading state - where the button contents are hidden, and the replaced by a centered spinning loading icon – without affecting the dimensions of the button. Currently there are two loading state icons available, --loading or --loading-refresh. Buttons in the loading state currently have a common look, regardless of the button style.

html
Copy

Notification indicator

A ds-button can be trigger to display a notification indicator (dot) by adding the class --notification. The notification indicator works with all button styles and visual states.

html
Copy

Notification indicators adhere to 4x preset visual states - alert, warning, success and info.

html
Copy

Additionally, if the button has an attribute data-notification-counter set to a non-empty value, that value will be shown in the indicator. If the attribute is set to empty data-notification-counter="" the indicator dot will be hidden.

html
Copy

Text addon inside buttons

ds-text can be used inside ds-button. See ds-text for further examples.

ds-button can also act as an addon to a field, see below.

Buttons inside other components

When ds-button is used inside ds-select, ds-input, or ds-range it will be displayed next to the element and will not wrap when the window is scaled.

html
Copy

Addon button

The --addon styles slightly modify the button to ‘join’ the containing component.

Addon default style

html
Copy

Styles

Custom styles exist for specific use cases. See also the basic buttons styles.

Buttons can be styled as links.

Button with label style

html
Copy

Button with link style and icon

html
Copy

Button with link style and tiny inline icon

html
Copy

Label style

Buttons can be styled as labels. A common usage would be in ds-datatable th headers for sorting columns.

Button with label style

html
Copy

Button with label style and icon

html
Copy

Button with label style and tiny inline icon

html
Copy

Button with label style

html
Copy

Inside ds-header

html
Copy

Feature style

html
Copy

Close style

Button with close style

html
Copy

in-place

--in-place is a shortcut class, often used in a datatable, when a button needs to sit adjacent to text for editing purposes. It is equivilent to ds-button.--xxsmall.--plain.--hide-label.

Button with close style

html
Copy

Tests

ds-tag inside ds-button

html
Copy

<button>

<button> with default button style

html
Copy

<button> with primary button style

html
Copy

<button> with plain button style

html
Copy

<a>

<a> with default button style

html
Copy

<a> with primary button style

html
Copy

<a> with plain button style

html
Copy

<ui-button>

Enabled button - simplified Angular example

html
Copy

Disabled button - simplified Angular example

html
Copy

Recommendations

Styling of delete buttons

All delete buttons should use the .--alert visual state and --icon-delete icon, with the appropriate buttons style (default, primary or plain).

html
Copy

Buttons should be used when performing an action such as confirming or canceling a dialog, submitting a form or triggering a UI component.

Links should be preferred when performing an adjacent task such as navigating to a new page, opening a help document in a new window.

Manifest

The component manifest describes this component's API — its modifiers, structure, data attributes, CSS custom properties, accessibility notes, and example markup. It is consumed by tooling such as AI assistants and code generators.

Latest version: https://assets.soracom.io/sds/latest/ds-button/index.mjs

index.mjs
Copy