Skip to content
On this page

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.

vue
<template>
  <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>
</template>

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

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

vue
<template>
  <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>
</template>

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

Sizes

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

vue
<template>
  <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>
</template>

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

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

vue
<template>
  <Btn block size="lg" type="primary">Block level button</Btn>
  <Btn block size="lg">Block level button</Btn>
</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).

vue
<template>
  <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>
</template>

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

Disabled state

Add disabled to make buttons unclickable.

vue
<template>
  <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>
</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

vue
<template>
  <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>
</template>
<script setup>
import { ref } from 'vue';
import { Btn, BtnGroup, Alert } from 'uiv';

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

Radio example

vue
<template>
  <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>
</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.

Released under the MIT License.