Buttons

Automatically included in all.css and elements.css. This stylesheet provides a robust set of button styles.

ts
import '@brainandbones/skeleton/styles/elements/buttons.css';
html
<button class="btn bg-primary-500 btn-base text-white">Skeleton</button>

Usage

Button

Add the .btn class to any button or anchor to create a button with minimal styling.

html
<button class="btn">Button</button>
html
<a href="/" class="btn">Anchor</a>
Anchor

Icon Buttons

Add the .btn-icon class to any button or anchor to create a icon button with minimal styling.

html
<button class="btn-icon">B</button>
html
<a href="/" class="btn-icon">A</a>
A

Styling

Use Tailwind utilty classes to enhance the button styling.

html
<button class="btn bg-primary-500">Skeleton</button>

Sizes

Adjust the button size with .btn-[sm|base|lg|xl]. Sizing is controlled using text size and padding.

html
<button class="btn btn-lg bg-primary-500">Large</button>

Adjust the icon button size with .btn-icon-[sm|base|lg|xl]. Sizing is controlled using text size, aspect square, and width.

html
<button class="btn-icon btn-icon-lg bg-primary-500">lg</button>

Leading and Trailing Icons

By default, buttons use flex-row and space-x-4 to create an evenly spaced row. Wrap children with span tags to ensure spacing works as expected.

html
<button class="btn bg-primary-500">
	<span>💀</span>
	<span>Icons</span>
	<span>🦴</span>
</button>

Variants

A set of canned preset styles are available using .btn-[variant]. This works for both standard and icon buttons.

html
<button class="btn btn-filled-primary">filled-primary</button>
html
<button class="btn-icon btn-filled-primary">💀</button>

SvelteKit Link Options

Since we use native elements, this means we can utilize SvelteKit Link Options such as a prefetch.

html
<a href="/" class="btn" data-sveltekit-prefetch>Skeleton</a>

Global Styles

Use your global stylesheet to update all instances of this element.

css
.btn {
	@apply font-bold rounded;
}
.btn-icon {
	@apply font-bold;
}
.btn-filled-primary,
.btn-filled-accent,
.btn-filled-warning,
.btn-filled-surface {
	@apply text-white;
}

Classes

Class Values Description
.btn-Creates a text button using a button or anchor.
.btn-icon-Creates a text icon button using a button or anchor.
.btn-[size]sm | base | lg | xlCanned button sizes that define padding and text sizes.
.btn-icon-[size]sm | base | lg | xlCanned icon button sizes that define padding and text sizes.
.btn-[variant]filled-primary | ghost | etc.A set of preset class styles for buttons or icon buttons.