Skip to content

ACV Button

Button is used to highlight key actions and clearly inform user of what will happen after the interaction.

Use buttons for actions in forms, dialogs, and much more.

It supports multiple variants, sizes, and states.

Overview

Source code
vue
<script setup>
  import AcvButton from '@/components/button/button.vue';
</script>

<template>
  <AcvButton>Button</AcvButton>
</template>

Types

Source code
vue
<script setup>
  import AcvButton from '@/components/button/button.vue';
</script>

<template>
  <AcvButton type="primary">
    Primary
  </AcvButton>
  <AcvButton type="secondary">
    Secondary
  </AcvButton>
  <AcvButton type="ghost">
    Ghost
  </AcvButton>
  <AcvButton type="danger">
    Danger
  </AcvButton>
  <div
    class="dark"
  >
    <AcvButton type="inverted">
      Inverted
    </AcvButton>
  </div>
</template>

<style scoped>
.acv-button {
  margin-block: 8px;
  margin-inline: 8px;
}

.dark {
  background-color: var(--acv-color-nav-primary);
  padding-inline: 8px;
  display: inline-flex
}
</style>

States

Buttons can have different states. They support active, focus, hover, and disabled states.

Use disabled=true to disable button.

Source code
vue
<script setup>
  import { IconAcronisIcon32 } from '@acronis-platform/icons/acronis';
  import { BUTTON_TYPE } from '@/components/button/button.ts';
  import Button from '@/components/button/button.vue';

  const buttonTypes = [
    'primary',
    'secondary',
    'ghost',
    'inverted',
    'danger'
  ];
</script>

<template>
  <div class="acv-grid-row acv-grid--cols-3">
    <div
      v-for="type in buttonTypes"
      :key="type"
      align="center"
      :width="8"
      :class="{
        'acv-bg-nav-primary': type === BUTTON_TYPE.inverted,
      }"
    >
      <Button :type="type">
        <IconAcronisIcon32 />
        Default {{ type }}
      </Button>
      <Button
        :type="type"
        class="hover"
      >
        Hover {{ type }}
      </Button>
      <Button
        :type="type"
        class="active"
      >
        Active {{ type }}
      </Button>
      <Button
        :type="type"
        class="focus"
      >
        Focus {{ type }}
      </Button>
      <Button
        :type="type"
        disabled
      >
        Disabled {{ type }}
      </Button>
    </div>
  </div>
</template>

<style scoped>
  .acv-cell {
    padding-block: 16px;
    padding-inline: 16px;
  }

  .acv-button {
    margin-block: 10px;
    display: block;
  }
</style>

Default state

Default state shows that button is clickable and user can perform a task on it

Hovered state

Once button is hovered by mouse cursor, it enters hover state, and it changes its color to a darker shade. This change indicates that user can interact with it.

Focused state

Focused state is when button is selected by keyboard navigation. It is indicated by a blue outline around the button. It is like a hover state, but it is triggered by keyboard navigation.

Disabled state

Disabled state is when button is not interactable with user. Nothing happens when user clicks on it.

Disabled state is represented with a lighter shade of color.

Active, pressed state

Active state is when button is clicked and user is holding the mouse button. It is represented by a darker shade of color and inner shadow.

Selected state

Selected state normally is used for toggle buttons or with set of buttons to indicate selected button within grouping. It is only applied when user has selected the button.

Loading state

Use the loading prop to show a loading spinner inside the button.

Button content will be disabled and visually hidden while loading.

Source code
vue
<script setup>
  import { ref } from 'vue';
  import Button from '@/components/button/button.vue';
  import AcvCheckbox from '@/components/checkbox/checkbox.vue';
  import Row from '@/components/row/row.vue';

  const isLoading = ref(true);
</script>

<template>
  <AcvCheckbox
    v-model="isLoading"
    class="mb-16"
  >
    Toggle loading
  </AcvCheckbox>
  <Row gutter="24">
    <Button
      :loading="isLoading"
    >
      Default button
    </Button>
    <Button
      :loading="isLoading"
      size="large"
    >
      Large button
    </Button>
  </Row>
</template>

<style scoped>
.acv-button {
  &+& {
    margin-left: 16px;
  }
}
</style>

Success state

Using success state is a good way to indicate that the action was successful.

Use the success prop to show a success state.

Sizing

Use size=large to specify bigger buttons.

Source code
vue
<script setup>
  import AcvButton from '@/components/button/button.vue';
  </script>

<template>
  <div class="acv-grid-row acv-grid--cols-2">
    <AcvButton>
      Default button
    </AcvButton>
    <AcvButton size="large">
      Large button
    </AcvButton>
    <AcvButton variant="outline">
      Default button
    </AcvButton>
    <AcvButton
      variant="outline"
      size="large"
    >
      Large button
    </AcvButton>
  </div>
</template>

With icons

Use icon and prepend-icon props to add icons to buttons. Also, you can use inline icons in default slot.

Source code
vue
<script setup>
  import { IconToCloud16 } from '@acronis-platform/icons/to';
  import { IconFromCloud16 } from '@acronis-platform/icons/from';
  import Button from '@/components/button/button.vue';
  </script>

<template>
  <div class="acv-grid-row acv-grid--cols-3">
    <Button
      :icon="IconToCloud16"
      size="large"
    >
      Prepend icon
    </Button>
    <Button
      size="large"
      :icon="IconToCloud16"
      :append-icon="IconFromCloud16"
    >
      Two icons
    </Button>
    <Button
      size="large"
      :append-icon="IconFromCloud16"
    >
      Append icon
    </Button>
    <Button>
      <IconToCloud16 />
      Prepend inline icon
    </Button>
    <Button>
      <IconToCloud16 />
      Two inline icons
      <IconFromCloud16 />
    </Button>
    <Button>
      Append inline icon
      <IconFromCloud16 />
    </Button>
  </div>
</template>

<style scoped>
.acv-button {
  margin-block: 10px;
}
</style>

Button types

By default <acv-button> renders a <button> element. You can change the type of the button by setting the buttonType prop. Also, you can render a <a> element by setting the href prop. You may generate router-links by setting the to prop.

TIP

Type prop is only available when the button is rendered as a <button> element. It is ignored when either href or to props are set.

Source code
vue
<script setup>
  import AcvButton from '@/components/button/button.vue';
</script>

<template>
  <AcvButton button-type="button">
    Button
  </AcvButton>
  <AcvButton button-type="submit">
    Submit
  </AcvButton>
  <AcvButton button-type="reset">
    Reset
  </AcvButton>
  <AcvButton
    button-type="link"
    href="#"
  >
    Link
  </AcvButton>
  <AcvButton
    button-type="route"
    to="#"
  >
    Router link
  </AcvButton>
</template>

<style scoped>
  .acv-button {
    margin-right: 8px;
  }
</style>

With single icon

Source code
vue
<script setup>
  import { IconAddressBook32 } from '@acronis-platform/icons/address';
  import Button from '@/components/button/button.vue';
  </script>

<template>
  <div class="acv-grid-row acv-grid--cols-3">
    <Button
      :icon="IconAddressBook32"
      size="large"
    />
    <Button :icon="IconAddressBook32" />
    <Button size="small">
      <IconAddressBook32 />
    </Button>

    <Button
      :icon="IconAddressBook32"
      size="large"
      variant="ghost"
    />
    <Button
      :icon="IconAddressBook32"
      variant="ghost"
    />
    <Button
      size="small"
      variant="ghost"
    >
      <IconAddressBook32 />
    </Button>

    <Button
      :icon="IconAddressBook32"
      size="large"
      variant="outline"
    />
    <Button
      :icon="IconAddressBook32"
      variant="outline"
    />
    <Button
      size="small"
      variant="outline"
    >
      <IconAddressBook32 />
    </Button>
  </div>
</template>

<style scoped>
.acv-button {
  margin-block: 10px;
}
</style>

Block buttons

Create block buttons that use full width of the parent container. Set up the block prop to make the button full width.

Source code
vue
<script setup>
  import Button from '@/components/button/button.vue';
</script>

<template>
  <Button
    block
    variant="primary"
  >
    Block Button
  </Button>
</template>

Accessibility

Provided AcvButton component must adapt to the list of WAI-ARIA accessibility patterns.

Overview

The button component is a simple button that allow users to trigger an action or event, such as submitting a form, opening dialog or performing operations.

We provide the following features to make the button accessible:

  • Accessible label (attribute to provide a label that describes the button's action): by default it will be text content inside the AcvButton component, but it can be provided by applying aria-label or aria-labelledby .
  • Accessible description (attribute sets ID of the element that describes the button): it can be provided by applying aria-describedby.
  • Inaccessible button (if button action is not available): by applying aria-disabled attribute.
  • Toggle button (if button has a toggle state): by applying aria-pressed attribute.

WAI-ARIA attributes

  • role="button" attribute to make the button accessible.
  • aria-disabled attribute to indicate that the button is disabled.
  • tabindex attribute to make the button focusable.
  • aria-pressed attribute to indicate the current state of the button.
  • aria-expanded attribute to indicate the current state of the button.
  • aria-haspopup attribute to indicate that the button has a popup.
  • aria-controls attribute to indicate the element that the button controls.
  • aria-label attribute to provide a label that describes the button's action. This is especially useful when the button contains only an icon.
  • aria-labelledby attribute to indicate the element that labels the button.
  • aria-describedby attribute to indicate the element that describes the button.
  • aria-owns attribute to indicate the element that the button owns.
  • aria-haspopup attribute to indicate that the button has a popup.
  • aria-haspopup attribute to indicate that the button has a popup.

Keyboard interaction

  • Enter or Space key to activate the button.

When href or to props are set, the button is rendered as an <a> element with role="button" attribute.

See also

Props

Prop nameDescriptionTypeValuesDefault
typeButton typeAcvButtonTypeprimary, secondary, ghost, danger, inverted
variantButton variantAcvButtonVariantsolid, outline, ghost, lightsolid
colorColor of the buttonButtonColorprimary, secondary, inverted, neutral, info, warning, success, critical, danger, infoprimary
isButton tag"a" | "span" | "button" | "label" | TSTypeQuerya, span, button, label, RouterLinkbutton
buttonTypeButton typeTSIndexedAccessTypebutton, submit, resetbutton
iconButton icon, accepts an icon name of Icon componentIconProp-
sizeButton sizeAcvButtonSizesmall, medium, largemedium
selectedWhether button appearance as selectedboolean-
autofocusSame as native button's autofocusboolean-
disabledDisable the buttonboolean-
loadingDetermine whether it's loadingboolean-
appendIconButton icon on the right side,
accepts any Icon component
IconProp-
blockWhether the button is block styled or notboolean-false
pillWhether the button is rounded or notboolean-false
squaredWhether the button is squared or notboolean-false

Slots

NameDescriptionBindings
prependLeft side slot content
defaultThe default slot content
appendRight side slot content

MIT Licensed