Button component

The kit:btn component is a central component of Lapikit. It allows you to create buttons that are adaptable, accessible and easily customized, either via props or CSS variables.

It automatically manages variants, states (active, loading, etc.), accessibility, colors, sizes, and integrates with icons or additional content (prepend, append, load).

button.svelte

Examples of button

Variants

Variants control the overall style of the button. They enable adaptation to different interface contexts, while maintaining visual consistency.

  • filled (default): solid button, generally used for main actions.

  • outline: button with outline, often used for secondary actions.

  • text: discreet button with no background or border, perfect for actions in a text flow.

  • link: styled as a hyperlink, ideal for navigation or less prominent actions.

  • variant: 'filled' | 'outline' | 'text' | 'link' = 'filled'

button.svelte

size

The size prop adjusts the button’s height and font size. It allows you to create buttons that fit different contexts, from compact icon buttons to large call-to-action buttons.

  • size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'md'
button.svelte

icon

Add icon to render a square button width equals height. Useful for icon-only actions.

  • icon: boolean = false
button.svelte

prepend and append snippets

Use prepend and append to place icons or elements on either side of the label.

  • prepend: Snippet | undefined = undefined
  • append: Snippet | undefined = undefined
button.svelte

States

The kit:btn component can reflect several visual or functional states, useful for informing the user or managing interaction. These states can be combined in certain cases (e.g. loading + success), but some, such as disabled, take precedence over all.

Here are the main states available:

  • disabled: boolean = false
  • loading: boolean = false
  • active: boolean = false

Each state can be styled automatically via Lapikit themes or customized via CSS classes or variables.

button.svelte

Use the load snippet to replace the default ... spinner with custom content.

  • load: Snippet | undefined = undefined

block and wide

block makes the button stretch to its container’s full width. wide caps it at 16rem and is intended to be centered.

  • block: boolean = false
  • wide: boolean = false
button.svelte

Pass href to render the button as an <a> element. The disabled prop removes href automatically.

  • href: string | undefined = undefined
button.svelte

Without preprocess Lapikit

If you aren’t using the Lapikit preprocessor in svelte.config.js, import the component directly:

API Reference

kit:btn

propstypedescriptiondefault
isenum'button''a''input'HTML element to render. Overridden by href or input.'button'
variantenum'filled''outline''text''link'Visual style.'filled'
sizeenum'xs''sm''md''lg''xl'Height and font size.'md'
densityenum'compact''default''comfortable'Padding and height multiplier.'default'
roundedenum0'xs''sm''md''lg''xl'Border radius.
hrefstringRenders as <a>. Cleared when disabled.
disabledbooleanPrevents interaction, dims the button.false
loadingbooleanShows a spinner, hides content.
activebooleanApplies the pressed background.false
iconbooleanMakes width equal height for icon-only buttons.
blockbooleanStretches to full container width.
widebooleanCaps width at 16rem.
noRipplebooleanDisables the ripple animation on click.
prependSnippetContent before the label.
appendSnippetContent after the label.
loadSnippetCustom spinner content shown while loading.
childrenSnippetButton label.

kit:btn become more effective with Tooltips, a Toolbar or Popover interactions.