Skip to content

CdsFunctionalButton

New in v4.0

A functional button is a utility action next to the content: download a file in a row of a list, reveal a password in a field, collapse a block, open the menu of a record. It is a CdsButton with size="sm", variant="soft" and color="neutral" fixed in place: the background is transparent and appears only on hover, so the button does not compete for attention with the content it stands next to.

Storybook GitLab
Test coverage: 100% — good coverage
API in specs
15 / 15 props, events, slots and exposed members with a test
Test cases
6 unit · 0 browser
Code coverage
100% lines · 100% branches measured in v4.0.0-alpha.13
A11y (axe)
3 recommendations in 9 stories measured in v4.0.0-alpha.11

Style the primary action of the screen — "Save", "Submit the request" — with CdsButton, and a navigation inside a paragraph with CdsLink. If the icon triggers nothing and only explains the content, leave it as CdsIcon.

Variations ​

Icon ​

The icon prop sets the icon — the usual look of a functional button. Such a button has no text, so add an aria-label: it stays the only name of the action.

Content ​

The default slot replaces the icon with your own content — a short label for an action that an icon cannot explain, for example.

States ​

The loading prop shows the progress of an operation instead of the icon, disabled dims the button and forbids pressing it, and readonly keeps the button looking regular but takes it out of the focus order and blocks the click.

Pass href (or to with a RouteLocationRaw object from vue-router) — the button renders as an a tag with all the link attributes, keeping its look.

Guidelines ​

Scenarios ​

Actions in a row of a list ​

Download and delete are actions on a particular record, not on the screen. The buttons stand at the right edge of the row, and an aria-label with the name of the document tells the buttons of the neighboring rows apart.

A button inside an input ​

In the append-inner and prepend-inner slots of the inputs a functional button fits the size of the field exactly. Here it toggles type between password and text, and the aria-label changes together with the icon.

Copying a value ​

A button next to a value copies it into the clipboard: loading shows the short operation, and the check icon confirms the result and turns back into copy a couple of seconds later.

Collapsing a block ​

A chevron expands and collapses a section: the icon changes together with the state, and aria-expanded reports it to the screen reader.

API ​

Props

NameTypeDefaultDescription
activeColorstring | undefined—Color of the component in its active state
baseColorstring | undefined—Color of the component in its inactive state
colorstring | undefined—Component color
disabledboolean | null | undefinednullDisabled state
exactboolean | undefined—If true, the active state applies only on an exact route match
hrefstring | undefined—The href attribute of the link. When set, the component behaves as a regular link
iconIconValue | undefined—Icon
loadingstring | boolean | undefined—Loading indicator for the component
readonlyboolean | null | undefinednullRead-only state
replaceboolean | undefined—If true, navigation replaces the current history entry instead of pushing a new one
tagstring | JSXComponent<any> | undefined'button'Custom HTML tag or component to render
themestring | undefined—Component theme
toLinkTo | undefined—Target route or route location object for RouterLink. When set, the component behaves as a RouterLink

Slots

NameTypeDescription
defaultanyContent inside the button
loaderanyLoading indicator