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.
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> 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> 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 | Name | Type | Default | Description |
|---|---|---|---|
size | String: 'xs', 'sm', 'md', 'lg', or 'xl' | 'md' | Size of button |
href | String | If present, a (anchor tag) is used to style a link as a button | |
target | String | Used with href to set the anchor tag's target attribute | |
type | String: 'button', 'submit', 'reset | Sets the button type attribute | |
active | Boolean | false | Display as active button (brighter) |
loading | (todo) | ||
variant | (todo) | ||
class | String | 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 |
| Name | Type | Default | Description |
|---|---|---|---|
--ui-button-color | Color | #fff | Color used for text and icons |
--ui-button-background | Color | #3b82f6 | Color used for Button background color |
--ui-button-width | Numeric | auto | Button component width |
--ui-button-height | Numeric | auto | Button component height |
--ui-button-padding | Padding shorthand | CSS padding shorthand | |
--ui-button-font-size | Numeric | 14px | Font size of Button text |
--ui-button-border | Border shorthand | none | CSS border shorthand |
--ui-button-radius | Numeric | --ui-border-radius or 3px | Button border radius |
--ui-button-shadow | Box shadow shorthand | 0 2px 2px 0 rgba(0, 0, 0, 0.2) | CSS box shadow shorthand |
| Name | Description |
|---|---|
icon | (todo) |
iconTrailing | (todo) |