Button

Buttons include simple button styles for actions in different types and sizes.

     

Add the btn class to <a>, <input> or <button> elements for a default button. There are classes btn-primary and btn-link for predefined primary and link buttons.

<script>
    import {Button} from 'svelte-spectre'
</script>

<Button>default button</Button>
<Button variant="primary">primary button</Button>
<Button variant="link">link button</Button>

Button variants

Add the btn-success or btn-error class for success (green) or error (red) button color. If you need more button colors, please use button mixins to create your own button color variants.

         

<Button variant="success">default button</Button>
<Button variant="error">link button</Button>

Button sizes

Add the btn-sm or btn-lg class for small or large button size. Also, you can add the btn-block class for a full-width button.

           

<Button size="xxl">XXL button</Button>
<Button size="xl">XL button</Button>
<Button size="lg">LG button</Button>
<Button size="md">MD button</Button>
<Button size="sm">SM button</Button>
<Button size="xs">XS button</Button>

Button icon

Please note that you could use the btn-action class for a square button, or add another s-circle class for a round button, which is often used as a Float Action Button (FAB).

           

<IconButton icon="home" variant="primary" size="sm"/>
<IconButton icon="flag" variant="primary" shape="circle" size="lg"/>

     

<Button variant="primary" size="sm"><Icon icon="arrow-down" />&nbsp; Button</Button>
<Button variant="primary" size="xs">Button &nbsp;<Icon icon="arrow-down" /></Button>

Button states #

Add the active class for active button state style.

     

<Button active>default active</Button>

Add the disabled class or the disabled attribute for disabled button state style.

     

<Button disabled>default disabled</Button>

A button with the loading class can show loading indicator.

     

<Button loading>default loading</Button>

Button groups

If you want to use buttons as a group, add the btn-group class to the container. You can add the btn-group-block class for a full-width button group.

<ButtonGroup block>
    <Button>default button</Button>
    <Button variant="primary">primary button</Button>
    <Button variant="link">link button</Button>
</ButtonGroup>
© 2022 — 2023 BASF SE

API Button

variant: Variant = "default"
Button variant
default | link | primary | secondary | success | error
size: Size = "md"
Button size
xs | sm | md | lg | xl | xxl
icon: Icons
Button icon
arrow-up | arrow-right | arrow-down | arrow-left | upward | forward | downward | back | caret | menu | apps | more-horiz | more-vert | resize-horiz | resize-vert | plus | minus | cross | check | stop | shutdown | refresh | search | flag | bookmark | edit | delete | share | download | upload | copy | mail | people | message | photo | time | location | link | emoji | xray | home | circle-check | wifi | audio
shape: Shape = false
Button shape
square | circle
state: State
Button state
active | disabled | loading
block: boolean = false
Button block
true | false