SfButton is an input that allows for user-triggered actions when clicked or pressed. This can be used for submitting forms, opening/closing dialogs, and much more.
Examples
Button sizes
SfButton supports 3 sizes that can be set with the size prop: 'sm', 'base', 'lg'.
You can truncate button content with Tailwind using max-w- and truncate classes.
<template>
<SfButton>
<span class="truncate max-w-[200px]"> Too long description for button </span>
</SfButton>
</template>
<script lang="ts" setup>
import { SfButton } from '@storefront-ui/vue';
</script>
Button content
SfButton provides prefix and suffix slots that you can use to add custom content before/after your default content. This can be useful for adding icons or badges to your buttons.
Button component can be rendered as <button> or <a> or any other tag by providing it with prop tag. When rendered as <button> this component applies default type='button' if no other type is passed as a prop.
Avoid using buttons to navigate the page. Use links or tabs.
If you need to use Button with non-<button> tags like <div> you need to add role='button'. When this role is added to an element, the browser will send out an accessible alert event to assistive technology products which can then notify the user. You can override this behaviour by passing role prop by yourself.