Svelte 5 component · fractalsvelte-ui · Navigation
Header
A top application bar featuring dedicated slots for brand identity, center search or navigation, and contextual action controls with frosted glass aesthetics.
Install
Header is a Svelte 5 header component in @fractaldesign/fractalsvelte-ui. It works in SvelteKit and in any Svelte 5 app.
pnpm add @fractaldesign/fractalsvelte-uiImport
import { Header } from '@fractaldesign/fractalsvelte-ui';Usage
<Header sticky={true} bordered={true} height={'64px'}>Click me</Header>Props
Also accepts every attribute of HTMLAttributes, spread onto
the root element.
| Name | Type | Default |
|---|---|---|
sticky | boolean Whether the header sticks to the top of the viewport during scrolling | true |
bordered | boolean Whether to render a bottom border | true |
height | string Fixed height of the header (e.g. '64px') | '64px' |
class | string Additional CSS classes | '' |
Snippets
| Name | Type | Default |
|---|---|---|
brand | Snippet Brand / Logo section slot on the far left | — |
center | Snippet Central section slot for global search or navigation | — |
actions | Snippet Trailing actions slot for user controls or status indicators | — |
children | Snippet Default fallback slot | — |
Source
Show the Header.svelte source
<script lang="ts">
import type { Snippet } from 'svelte';
import type { HTMLAttributes } from 'svelte/elements';
export interface Props extends HTMLAttributes<HTMLElement> {
/** Whether the header sticks to the top of the viewport during scrolling */
sticky?: boolean;
/** Whether to render a bottom border */
bordered?: boolean;
/** Fixed height of the header (e.g. '64px') */
height?: string;
/** Additional CSS classes */
class?: string;
/** Brand / Logo section slot on the far left */
brand?: Snippet;
/** Central section slot for global search or navigation */
center?: Snippet;
/** Trailing actions slot for user controls or status indicators */
actions?: Snippet;
/** Default fallback slot */
children?: Snippet;
}
let {
sticky = true,
bordered = true,
height = '64px',
class: className = '',
brand,
center,
actions,
children,
...restProps
}: Props = $props();
</script>
<header
class="f-header {className}"
data-sticky={sticky}
data-bordered={bordered}
style="--header-height: {height};"
{...restProps}
>
{#if brand}
<div class="f-header-brand">
{@render brand()}
</div>
{/if}
{#if center}
<div class="f-header-center">
{@render center()}
</div>
{/if}
{#if actions}
<div class="f-header-actions">
{@render actions()}
</div>
{/if}
{#if children && !brand && !center && !actions}
{@render children()}
{/if}
</header>
<style>
@layer fractalsvelte-ui.components {
.f-header {
display: flex;
align-items: center;
justify-content: space-between;
height: var(--header-height, 64px);
padding: 0 var(--f-space-lg);
background: var(--f-surface);
color: var(--f-text);
gap: var(--f-space-md);
box-sizing: border-box;
transition: background var(--f-duration-fast) var(--f-ease),
border-color var(--f-duration-fast) var(--f-ease);
}
.f-header[data-sticky='true'] {
position: sticky;
top: 0;
z-index: 50;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.f-header[data-bordered='true'] {
border-bottom: 1px solid var(--f-border);
}
.f-header-brand {
display: flex;
align-items: center;
gap: var(--f-space-sm);
flex-shrink: 0;
}
.f-header-center {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
min-width: 0;
}
.f-header-actions {
display: flex;
align-items: center;
gap: var(--f-space-xs);
flex-shrink: 0;
}
}
</style>Related components
MobileNav A slide-out mobile drawer overlay with an animated backdrop, integrated dismissal trigger, and responsive…MorphingTabs A high-performance tabbed navigation bar featuring a physics-sliding, width-morphing highlight indicator…Pagination A comprehensive paged navigation control featuring previous/next triggers, dynamic page number buttons,…SegmentedControl A pill-style selection switch featuring a smooth sliding backdrop highlight that glides behind the actively…SideNav A collapsible vertical sidebar navigation menu supporting grouped section headings, nested badges, vector…Stepper A multi-step progress indicator tracking completed, active, and upcoming stages across discrete workflows…