Alert Avatar AvatarGroup Button ButtonGroup Checkbox CheckboxGroup FilePicker Form FormRow Hamburger Input Modal Option Radio RadioGroup Rating Select Spinner Textarea Toast Tooltip Toggle

Button

Button components are rendered as a button element by default or if an href property is passed, it will be rendered as a regular a anchor link element. Styling will be the same in either case.

Example

The default button uses --ui-focus value or #3b82f6 for color and md size.

<script>
  import { Button } from '$lib/ui';
</script>

<Button>
  Click Me
</Button>

Sizes

The size property can be used to select other button sizes. The default size is md (medium).

<Button size="xs">
  Click Me
</Button>

<Button size="sm">
  Click Me
</Button>

<Button size="md">
  Click Me
</Button>

<Button size="lg">
  Click Me
</Button>

<Button size="xl">
  Click Me
</Button>

Anchor Tag

If an href property is passed, the button will be rendered as a regular a anchor link element. All other props can still be used and styling will be the same in either case.

<Button href="https://svelte.dev">
  Explore Svelte
</Button>
Explore Svelte

Button Component Props

Name Type Default Description
sizeString: 'xs', 'sm', 'md', 'lg', or 'xl''md'Size of button
hrefString If present, a (anchor tag) is used to style a link as a button
targetString Used with href to set the anchor tag's target attribute
typeString: 'button', 'submit', 'reset Sets the button type attribute
activeBooleanfalseDisplay as active button (brighter)
loading(todo)  
variant(todo)  
classString CSS classes declared in global scope can be applied to the outermost element
...  Additional props will be passed through to the HTML element enabling support for things like disabled, on:click, target="_blank", etc

Button CSS Custom Properties

Name Type Default Description
--ui-button-colorColor#fffColor used for text and icons
--ui-button-backgroundColor#3b82f6Color used for Button background color
--ui-button-widthNumericautoButton component width
--ui-button-heightNumericautoButton component height
--ui-button-paddingPadding shorthand CSS padding shorthand
--ui-button-font-sizeNumeric14pxFont size of Button text
--ui-button-borderBorder shorthandnoneCSS border shorthand
--ui-button-radiusNumeric--ui-border-radius or 3pxButton border radius
--ui-button-shadowBox shadow shorthand0 2px 2px 0 rgba(0, 0, 0, 0.2)CSS box shadow shorthand

Button Named Slots

Name Description
icon(todo)
iconTrailing(todo)