NcButton
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
disabled | Toggles the disabled state of the button on and off. | boolean | - | false |
type | Specifies the button type Accepted values: primary, secondary, tertiary, tertiary-no-background, tertiary-on-primary, error, warning, success. If left empty, the default button style will be applied. | string | primary , secondary , tertiary , tertiary-no-background , tertiary-on-primary , error , warning , success | 'secondary' |
nativeType | Specifies the button native type Accepted values: submit, reset, button. If left empty, the default "button" type will be used. | string | submit , reset , button | 'button' |
wide | Specifies whether the button should span all the available width. By default, buttons span the whole width of the container. | boolean | - | false |
ariaLabel | Always try to provide an aria-label to your button. Make it more specific than the button's title by provide some more context. E.g. if the title of the button is "send" in the Mail app, the aria label could be "Send email". | string | - | null |
href | Providing the href attribute turns the button component into an a element. | string | - | null |
to | Providing the to attribute turns the button component into a router-link element. Takes precedence over the href attribute. | string|object | - | null |
exact | Pass in true if you want the matching behaviour of router-link tobe non-inclusive: https://router.vuejs.org/api/#exact | boolean | - | false |
Slots
Name | Description | Bindings |
---|---|---|
icon | The material design icon slot | |
default |
General description
General purpose button component. See props for different options. Use material design icons only for icons and remember to set their size to 20.
Usage
Custom icon slot
To be used with vue-material-design-icons
only. For icon classes use the default-icon
slot. It can be used with one or multiple actions.
<template>
<div class="wrapper">
<!-- Style selector -->
<div class="grid">
<NcCheckboxRadioSwitch :checked.sync="style" value="text" name="style" type="radio">Text only</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="style" value="icon" name="style" type="radio">Icon only</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="style" value="icontext" name="style" type="radio">Icon and text</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="disabled" type="checkbox">Disabled</NcCheckboxRadioSwitch>
<!--<NcCheckboxRadioSwitch :checked.sync="readonly" type="checkbox">Read-only</NcCheckboxRadioSwitch>-->
</div>
<h5>Standard buttons</h5>
<div class="grid">
<p>Tertiary, no background</p>
<p>Tertiary</p>
<p>Secondary</p>
<p>Primary</p>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="tertiary-no-background">
<template v-if="style.indexOf('icon') !== -1" #icon>
<Video
:size="20" />
</template>
<template v-if="style.indexOf('text') !== -1">Example text</template>
</NcButton>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="tertiary">
<template v-if="style.indexOf('icon') !== -1" #icon>
<Video
:size="20" />
</template>
<template v-if="style.indexOf('text') !== -1">Example text</template>
</NcButton>
<NcButton
:disabled="disabled"
:readonly="readonly">
<template v-if="style.indexOf('icon') !== -1" #icon>
<Video
title=""
:size="20" />
</template>
<template v-if="style.indexOf('text') !== -1">Example text</template>
</NcButton>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="primary">
<template v-if="style.indexOf('icon') !== -1" #icon>
<Video
:size="20" />
</template>
<template v-if="style.indexOf('text') !== -1">Example text</template>
</NcButton>
</div>
<!-- Wide button -->
<h5>Wide button</h5>
<NcButton
:disabled="disabled"
:readonly="readonly"
:wide="true"
text="Example text">
<template #icon>
<Video
title=""
:size="20" />
</template>
Example text
</NcButton>
<!-- Special buttons -->
<h5>Special buttons</h5>
<div class="grid">
<p>Success</p>
<p>Warning</p>
<p>Error</p>
<p> - </p>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="success">
<template #icon>
<Video
:size="20" />
</template>
Example text
</NcButton>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="warning">
<template #icon>
<Video
title=""
:size="20" />
</template>
Example text
</NcButton>
<NcButton
:disabled="disabled"
:readonly="readonly"
type="error">
<template #icon>
<Video
:size="20" />
</template>
Example text
</NcButton>
<p> - </p>
</div>
</div>
</template>
<script>
import Video from 'vue-material-design-icons/Video'
export default {
components: {
Video,
},
data() {
return {
toggled: false,
disabled: false,
readonly: false,
style: 'icontext',
}
}
}
</script>
<style lang="scss" scoped>
.wrapper {
padding: 0 12px;
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: repeat(auto-fill, auto);
position: relative;
margin: 12px 0;
}
h5 {
font-weight: bold;
margin: 40px 0 20px 0;
}
p {
text-align: center;
margin: 4px 0 12px 0;
color: var(--color-text-maxcontrast)
}
button {
margin: auto;
}
</style>