Skip to content
On this page

Button

A Native <button /> with batteries included for loading state, variants & many more.

Preview & Playground 🖼️

Here you may find a preview of the component, with error & possible variants.

🏄 Click to expand the code
vue
<script setup lang="ts">
import { Button } from '@flavorly/vanilla-components'
</script>

<template>
  <PreviewWrapper>
    <div class="flex flex-col items-center justify-center mx-auto space-y-3 ">
      <!-- Regular -->
      <Button label="Complete Order" />

      <!-- Primary -->
      <Button
        label="All Good!"
        variant="primary"
      />

      <!-- Errors -->
      <Button
        variant="error"
        label="Cancel Order"
      />

      <!-- Errors Soft -->
      <Button
        variant="errorSoft"
        label="Are you sure?"
      />

      <!-- Success -->
      <Button
        variant="success"
        label="Confirmed"
      />

      <!-- With Indicator -->
      <span class="relative inline-flex">
        <Button
          label="New Orders"
          class="focus:ring-0 focus:ring-offset-0 focus:border-primary-600"
        />
        <span class="flex absolute h-3 w-3 top-0 right-0 -mt-1 -mr-1 z-10">
          <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-primary-400 opacity-75" />
          <span class="relative inline-flex rounded-full h-3 w-3 bg-primary-500" />
        </span>
      </span>

      <!-- Primary & Loading -->
      <Button
        label="Processing"
        variant="primary"
        :loading="true"
      />

      <!-- Primary & Loading -->
      <Button
        label="Processing"
        :loading="true"
      />

      <!-- Loading & Disabled -->
      <Button
        label="Processing & Disabled"
        :loading="true"
        :disabled="true"
      />

      <!-- Loading & Disabled -->
      <Button
        label="Disabled"
        :disabled="true"
      />

      <!-- Transparent -->
      <Button
        label="Transparent"
        variant="transparent"
      />
    </div>
  </PreviewWrapper>
</template>

Props 📥

Props available for this component extending the default variant & global props.

PropDescriptionAccepted ValuesDefault
asTag to render the buttonString'button'
labelLabel & text for the buttonString'button'
loadingDisable & Sets as loadingBooleanfalse
disabledDisable the buttonBooleanfalse
typeType of the button Ex: submitString'button'
focusOnMountAuto-focus on mountBooleanfalse

Slots 🧬

Current slots available for this component are the following:

Slot default

Default slot, overrides everything inside the button, please beware that this will disable the loading and disable states

Slot icon

Appends an icon, allowing an icon to be inserted together with the loading state

Slot label

Label to use inside the button, as you would expect from a normal button

Events 🚇

Here you may find the events emitted by this component.

EventDescriptionValue
clickWhen element is clickedBoolean

Released under the MIT License.