Button
Button styling can be applied to either button or link elements. Use the appropriate element for the task: use a button element when the user is performing an action, use a link element when the user is navigating.
Types of button
Primary (default)
Use this for your primary calls to action. Multiple primary buttons can confuse users. Try to have only one of these per page (or section of a page).
Sample HTML
<p><button class="ds_button">Start here</button></p>
Secondary
Any non-primary actions should use this inverted button style. It has less visual prominence than the primary button.
Sample HTML
<p><button class="ds_button ds_button--secondary">View summary</button></p>
Cancel/calloff
If a button is used to cancel or back out of an action, this more severe border style should be used.
Sample HTML
<p><button class="ds_button ds_button--cancel">Cancel</button></p>
Disabled
Buttons in a disabled or unclickable state should be visually distinct and use this display.
Sample HTML
<p><button disabled="true" class="ds_button">Disabled button</button></p>
Width variants
Flexible (default)
Buttons will expand to fit the length of text by default
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button">Start</a><br />
<a href="#" class="ds_button">Really super duper start here</a>
</div>
Fixed
Use fixed-width buttons to force uniformity in button widths.
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button ds_button--fixed">Start</a><br />
<a href="#" class="ds_button ds_button--fixed">Really super duper start here</a>
</div>
Maximum
Use maximum-width buttons for large buttons. These will fill the width of small screens, up to a set maximum width (480px).
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button ds_button--max">Start</a><br />
<a href="#" class="ds_button ds_button--max">Really super duper start here</a>
</div>
Size variants
Small
A small button style is available for cases where one is necessary, such as when you have a group of buttons.
The small button modifier can be applied to any type or width variant.
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button ds_button--small">Start here</a><br />
<a href="#" class="ds_button ds_button--small ds_button--max ds_button--secondary">View summary</a><br />
<a href="#" class="ds_button ds_button--small ds_button--fixed ds_button--cancel">Cancel</a>
</div>
Buttons with icons
Icons can be added to buttons. Buttons with icons can also have any size, type or width modifiers applied to them.
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button ds_button--has-icon ds_button--max">
Search
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#search"></use></svg>
</a><br />
<a href="#" class="ds_button ds_button--small ds_button--secondary ds_button--has-icon">
Search
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#search"></use></svg>
</a><br />
<a href="#" class="ds_button ds_button--cancel ds_button--fixed ds_button--has-icon">
Cancel
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#close"></use></svg>
</a>
</div>
The icons can be aligned to either side of the button.
Sample HTML
<div class="button-group">
<a href="#" class="ds_button ds_button--cancel ds_button--has-icon ds_button--has-icon--left">
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#chevron_left"></use></svg>
Back
</a>
<a href="#" class="ds_button ds_button--has-icon">
Next
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#chevron_right"></use></svg>
</a>
</div>
Icon-only buttons
Buttons can also contain only an icon. If you do this, make sure that the intention of the button is clearly communicated in a way that is accessible to users of assistive technology.
Sample HTML
<div class="ds_button-group">
<a href="#" class="ds_button">
<span class="visually-hidden">Search</span>
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#search"></use></svg>
</a><br />
<a href="#" class="ds_button ds_button--small ds_button--cancel">
<span class="visually-hidden">Close</span>
<svg class="ds_icon" aria-hidden="true" role="img"><use xlink:href="/assets/images/icons/icons.stack.svg#close"></use></svg>
</a>
</div>
Website analytics
To track interactions with button elements in Google Analytics using Google Tag Manager, each button has a data attribute that describes the action.
The data attribute is added automatically by the Design System’s “tracking” script.
Feedback, help or support
If you need any help or want to give any feedback you can e-mail us at: designsystem@gov.scot