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.
Button as a link
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
| Name | Type | Default | Description |
|---|---|---|---|
activeColor | string | undefined | — | Color of the component in its active state |
baseColor | string | undefined | — | Color of the component in its inactive state |
color | string | undefined | — | Component color |
disabled | boolean | null | undefined | null | Disabled state |
exact | boolean | undefined | — | If true, the active state applies only on an exact route match |
href | string | undefined | — | The href attribute of the link. When set, the component behaves as a regular link |
icon | IconValue | undefined | — | Icon |
loading | string | boolean | undefined | — | Loading indicator for the component |
readonly | boolean | null | undefined | null | Read-only state |
replace | boolean | undefined | — | If true, navigation replaces the current history entry instead of pushing a new one |
tag | string | JSXComponent<any> | undefined | 'button' | Custom HTML tag or component to render |
theme | string | undefined | — | Component theme |
to | LinkTo | undefined | — | Target route or route location object for RouterLink. When set, the component behaves as a RouterLink |
Slots
| Name | Type | Description |
|---|---|---|
default | any | Content inside the button |
loader | any | Loading indicator |