Button

Use Bootstrap’s custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.

Examples

Use any of the available button types to quickly create a styled button.

<template>
  <div class="uiv">
    <Btn>Default</Btn>
    <Btn type="primary">Primary</Btn>
    <Btn type="success">Success</Btn>
    <Btn type="info">Info</Btn>
    <Btn type="warning">Warning</Btn>
    <Btn type="danger">Danger</Btn>
    <Btn type="link">Link</Btn>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Buttons with href or to prop will render as link tag.

Native links

DefaultPrimary

Vue Router links

DefaultPrimary
<template>
  <div class="uiv">
    <h4>Native links</h4>
    <Btn href="#">Default</Btn>
    <Btn href="#" type="primary">Primary</Btn>
    <h4>Vue Router links</h4>
    <Btn to="/">Default</Btn>
    <Btn to="/" type="primary">Primary</Btn>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Sizes

Fancy larger or smaller buttons? Add size lg, sm, or xs for additional sizes.

<template>
  <div class="uiv">
    <p>
      <Btn size="lg" type="primary">Large button</Btn>
      <Btn size="lg">Large button</Btn>
    </p>
    <p>
      <Btn type="primary">Default button</Btn>
      <Btn>Default button</Btn>
    </p>
    <p>
      <Btn size="sm" type="primary">Small button</Btn>
      <Btn size="sm">Small button</Btn>
    </p>
    <p>
      <Btn size="xs" type="primary">Extra small button</Btn>
      <Btn size="xs">Extra small button</Btn>
    </p>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Create block level buttons—those that span the full width of a parent — by adding block.

<template>
  <div class="uiv">
    <Btn block size="lg" type="primary">Block level button</Btn>
    <Btn block size="lg">Block level button</Btn>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Active state

Add active to make buttons appear pressed (with a darker background, darker border, and inset shadow).

Buttons

Links

Primary buttonButton
<template>
  <div class="uiv">
    <h4>Buttons</h4>
    <Btn active type="primary">Primary button</Btn>
    <Btn active>Button</Btn>
    <h4>Links</h4>
    <Btn active href="#" type="primary">Primary button</Btn>
    <Btn active to="/">Button</Btn>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Disabled state

Add disabled to make buttons unclickable.

Buttons

Links

Primary buttonButton
<template>
  <div class="uiv">
    <h4>Buttons</h4>
    <Btn disabled type="primary">Primary button</Btn>
    <Btn disabled>Button</Btn>
    <h4>Links</h4>
    <Btn disabled href="#" type="primary">Primary button</Btn>
    <Btn disabled to="/">Button</Btn>
  </div>
</template>

<script setup>
import { Btn } from 'uiv';
</script>

Checkbox / Radio

Add input-type to render <btn> as checkbox or radio input.

TIP

This needed to work with btn-group for correct styles.

Checkbox example



<template>
  <section class="uiv">
    <BtnGroup>
      <Btn v-model="model" input-type="checkbox" input-value="1"
        >Checkbox 1</Btn
      >
      <Btn v-model="model" input-type="checkbox" input-value="2"
        >Checkbox 2</Btn
      >
      <Btn v-model="model" input-type="checkbox" input-value="3"
        >Checkbox 3</Btn
      >
      <Btn v-model="model" input-type="checkbox" input-value="4" disabled
        >Checkbox 4 (Disabled)</Btn
      >
    </BtnGroup>
    <hr />
    <Alert>Selected: {{ model }}</Alert>
  </section>
</template>
<script setup>
import { ref } from 'vue';
import { Btn, BtnGroup, Alert } from 'uiv';

const model = ref(['1']);
</script>

Radio example



<template>
  <section class="uiv">
    <BtnGroup>
      <Btn v-model="model" input-type="radio" input-value="1">Radio 1</Btn>
      <Btn v-model="model" input-type="radio" input-value="2">Radio 2</Btn>
      <Btn v-model="model" input-type="radio" input-value="3">Radio 3</Btn>
      <Btn v-model="model" input-type="radio" input-value="4" disabled
        >Radio 4 (Disabled)</Btn
      >
    </BtnGroup>
    <hr />
    <Alert>Selected: {{ model }}</Alert>
  </section>
</template>
<script setup>
import { ref } from 'vue';
import { Btn, BtnGroup, Alert } from 'uiv';

const model = ref('1');
</script>

API Reference

Btn

Props

NameTypeDefaultRequiredDescription
typeStringdefaultButton types in Bootstrap. Supported: default, primary, info, success, warning, danger, link.
native-typeStringbuttonNative button type. Supported: button, submit, reset.
sizeStringOptional button sizes. Supported: lg, sm, xs.
blockBooleanfalseApply block level style.
activeBooleanfalseApply active state.
disabledBooleanfalseApply disabled state.
hrefStringAn native link will be created if this prop present.
targetStringNative link prop.
toString or ObjectAn Vue-Router link will be created if this prop present.
replaceBooleanfalseVue-Router link prop.
appendBooleanfalseVue-Router link prop.
exactBooleanfalseVue-Router link prop.
input-typeStringUse this prop to turn btn to checkbox or radio input. Supported types: checkbox / radio
input-valueThe value of input.
v-modelThe model of input. Note that this prop is required if input-type present.
justifiedBooleanfalseDue to Bootstrap limitation, this prop is needed while using <btn> in <btn-group justified>. Otherwise it can be ignored.

Slots

NameDescription
defaultThe button body.

Events

NameParamsDescription
clickClick event of button / link.