Components

Appbar component

The kit:appbar is an essential component for structuring an application’s header. It provides a dedicated space for displaying elements such as titles, icons, buttons or menus. Thanks to its many customization options, the kit:appbar integrates perfectly into a variety of designs, from minimalist to complex.

appbar.svelte
Lapikit
<script lang="ts">
	import { Bell, Search } from 'lucide-svelte';
</script>

<kit:appbar rounded="md">
	<span style="font-weight: 700; font-size: 1.1rem; margin-right: auto;">Lapikit</span>

	<nav style="display: flex; gap: 0.25rem;">
		<kit:btn variant="text" density="compact">Docs</kit:btn>
		<kit:btn variant="text" density="compact">Components</kit:btn>
	</nav>

	<span style="display: flex; gap: 0.25rem; margin-left: auto;">
		<kit:btn variant="text" density="compact" icon>
			<kit:icon><Search /></kit:icon>
		</kit:btn>
		<kit:btn variant="text" density="compact" icon>
			<kit:icon><Bell /></kit:icon>
		</kit:btn>
	</span>
</kit:appbar>

kit:appbar renders as a <header> by default. It wraps your content in an inner kit-appbar__wrapper div that fills the full width and aligns items in a row. Use classContent to apply a class to that wrapper typically to constrain the max-width of the content while the background spans the full width.

Examples of app bar

Base

The variant prop controls the background and border style, color gives the color.

  • filled (default): surface background (--kit-color-surface-1), or the color with a contrasted text.

  • tonal: light tint of the color, text in the color.

  • outline: transparent background with a border.

  • surface: very light tint of the color with a soft border.

  • text: transparent background, text in the color.

  • variant: 'filled' | 'tonal' | 'outline' | 'surface' | 'text' = 'filled'

  • color: string | false | { base?, active? } = undefined

appbar.svelte
<div style="display: flex; flex-direction: column; gap: 0.75rem;">
	{#each ['filled', 'tonal', 'outline', 'surface', 'text'] as variant (variant)}
		<kit:appbar rounded="md" {variant} color="accent">
			<span style="font-weight: 600;">{variant}</span>
		</kit:appbar>
	{/each}
</div>

Density

density adjusts the height and the padding of the appbar, from -4px (dense) to +4px (spacious).

  • density: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious' = 'default'
appbar.svelte
<div style="display: flex; flex-direction: column; gap: 0.75rem;">
	{#each ['dense', 'compact', 'default', 'comfortable', 'spacious'] as density (density)}
		<kit:appbar rounded="md" {density}>
			<span style="font-weight: 600;">{density}</span>
		</kit:appbar>
	{/each}
</div>

classContent

classContent applies a CSS class to the inner content wrapper. Use it to constrain the max-width of the content while the appbar background spans the full width.

  • classContent: string | array | object = undefined
appbar.svelte
<kit:appbar classContent="custom-appbar-inner">
	<span style="font-weight: 700; margin-right: auto;">Lapikit</span>
	<nav style="display: flex; gap: 0.5rem;">
		<kit:btn variant="text" density="compact">Docs</kit:btn>
		<kit:btn variant="text" density="compact">Components</kit:btn>
	</nav>
</kit:appbar>

<style>
	:global(.custom-appbar-inner) {
		max-width: 480px;
		margin-inline: auto;
	}
</style>

Without preprocess Lapikit

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

import { Appbar } from 'lapikit/components';

API Reference

kit:appbar

propstypedescriptiondefault
ref $bindableHTMLElementBindable reference to the rendered DOM element.null
isenum'div''header''nav'HTML element to render.'header'
classstring | array | objectClasses of the appbar, with the rules of Svelte (clsx).
stylestringInline style of the appbar.
s-classstring | array | objectClasses of the appbar, merged with class.
s-styleobjectInline style as an object of property / value pairs.
variantenum'filled''tonal''outline''surface''text'Visual style of the appbar.'filled'
densityenum'dense''compact''default''comfortable''spacious'Height and padding, from -4px to +4px.'default'
roundedenum0'xs''sm''md''lg''xl''full'Border radius.0
colorstring | false | { base?, active? }Appbar color, its use depends on the variant.
classContentstring | array | objectClasses of the inner content wrapper (clsx).
childrenSnippetAppbar content.
elevationElevationStateenum'0''1''2''3''4''5'Add shadow effect.
sizeenum'xs''sm''md''lg''xl'Sizing height, font and gap for appbar.'md'

An effective kit:appbar goes well with Dropdown for menus and Avatars for identification.