@kern-ux-annex/webc v2.7.1
KERN Web Components Library
A comprehensive Web Components library built with Lit and TypeScript, implementing the complete KERN design system for German public administration.
Mit KERN schaffen wir einen offenen UX-Standard für die deutsche Verwaltung, der Umsetzende befähigt, barrierefreie digitale Verwaltungslösungen effizient und nutzendenzentriert zu entwickeln. KERN ist ein Open-Source-Projekt, das von der Ländern Hamburg und Schleswig-Holstein initiiert wurde. Alle mit Interesse an der Digitalisierung der öffentlichen Verwaltung sind herzlich eingeladen, Teil der bundesweiten interdisziplinären Community zu werden. Alle Informationen auf unserer Website.
Hinweise
Dieses Projekt befindet sich in aktiver Entwicklung. KERN 2 wurde am 27.5.2025 released. Diese Projekt basiert auf dem KERN – Plain-CSS-HTML-Kit in der Version 2.1.1 (oder höher). Es benutzt dessen CSS-Klassen und HTML Code Beispiele. Vielen Dank an das ganze KERN Projekt!
Die Dokumentation ist derzeit komplett in englischer Sprache. Dieses Projekt ist auch ein Testballon für KI-unterstützte Softwareentwicklung. Die "Zusammenarbeit" mit LLMs funktioniert derzeit noch besser über englische Inhalte.
Der jeweils aktuelle Storybook-Build ist unter https://kern-ux-webc.mein-service.net zu finden.
Beitragen
Die Entwicklung des KERN Design-Systems ist im Hauptrepository organisiert.
Für Bugs und Verbesserungsvorschläge, die sich ausschließlich auf den CSS/HTML-Code beziehen, schaue dir bitte unsere Contributing Guidelines an. Wir freuen uns auf deinen Beitrag!
Table of Contents
- Hinweise
- Beitragen
- Features
- Components
- Installation
- Quick Start
- Usage
- Storybook Integration
- Scripts & Commands
- Component Documentation
- Development
- Testing
- Publishing
- Performance & Bundle Size
- Browser Support
- License
- Contributing
- Design System
- Links & Resources
Features
- ✅ Built with Lit framework for standards-based web components
- ✅ TypeScript support with full type definitions
- ✅ KERN design system integration
- ✅ Comprehensive test suite
- ✅ Tree-shakeable builds
- ✅ Accessible components following ARIA guidelines
Components
This library includes 50+ production-ready components implementing the complete KERN design system, organized into logical categories:
🧭 Navigation & Layout Components
- kern-accordion - Collapsible content sections with accessible details/summary structure
- kern-breadcrumb / kern-breadcrumb-item - Navigation hierarchy with keyboard support
- kern-card - Versatile container with variants (default, hug, active, small, large)
- kern-card-media / kern-card-header / kern-card-body / kern-card-footer / kern-card-container - Card composition system
- kern-divider - Visual content separators with semantic meaning
- kern-grid-container / kern-grid-row / kern-grid-col - Responsive grid layout system
- kern-kopfzeile - Header/masthead component for site branding
- kern-menu / kern-menu-item - Accessible dropdown menus and navigation
- kern-tabs / kern-tab-panel - Tabbed content with variants (default, underlined, pills)
📝 Forms & Input Components
- kern-button - Interactive buttons with variants, icons, loading states, and block layout
- kern-checkbox - Accessible checkbox input controls with validation
- kern-checkbox-list - Grouped checkbox collections with fieldset structure
- kern-fieldset - Form field grouping with legend and validation support
- kern-input - Text inputs supporting all HTML5 types (text, email, password, number, tel, url, search, file)
- kern-label - Form labels with required indicators and accessibility features
- kern-radio - Radio button controls with group management
- kern-select - Dropdown selection controls with validation and custom styling
- kern-textarea - Multi-line text input with resize control and validation
💬 Feedback & Communication Components
- kern-alert / kern-alert-content - Status messages with dismissible functionality and variants
- kern-badge / kern-badge-icon - Small status indicators with icon support and color variants
- kern-dialog - Modal dialogs and overlays with multiple variants and focus management
- kern-loader - Loading states and spinner animations with size variants
- kern-progress - Progress bars and loading indicators with customizable styling
- kern-tooltip - Contextual information on hover/focus with positioning control
📄 Content & Typography Components
- kern-avatar - User profile pictures with fallback initials and customizable styling
- kern-body / kern-text - Body text with KERN typography system (size variants: large, default, small)
- kern-heading - Semantic headings (h1-h6) with 1:1 level-to-size mapping and override options
- kern-link - Enhanced links with icon support, variants, and accessibility features
- kern-list / kern-list-item - Styled lists (default, bullet, number) with size variants
- kern-preline - Pre-content text elements for introductory content
- kern-subline - Sub-content text with multiple size variants
- kern-title - Title text component with size variants for hierarchical content
📊 Data Display Components
- kern-description-list / kern-description-list-item - Key-value pair displays with copyable functionality
- kern-summary / kern-summary-group - Summary sections with numbered groups and collapsible content
- kern-table / kern-thead / kern-tbody / kern-tfoot / kern-tr / kern-th / kern-td - Complete table system with responsive design, sorting, and striping
- kern-task-list / kern-task-list-item / kern-task-list-group - Task management with status tracking and grouping
🎨 Display & Media Components
- kern-icon - Comprehensive icon system with the complete KERN icon library and size variants
🔧 Component Features
- Accessibility First: Full ARIA support, keyboard navigation, and screen reader compatibility
- Theme Support: Automatic light/dark theme handling with KERN design tokens
- Responsive Design: Mobile-first approach with breakpoint-aware components
- Form Integration: Native form validation and submission support
- Event System: Custom events with
kern-prefix for framework integration - TypeScript Support: Full type definitions for all properties and events
- CSS Custom Properties: Extensive theming through CSS variables
- Shadow DOM: Encapsulated styling preventing conflicts
- Tree Shakeable: Import only what you need for optimal bundle size
Installation
npm install @kern-ux-annex/webcQuick Start
Get started with KERN Web Components in just a few steps:
Install the package:
npm install @kern-ux-annex/webcImport components in your project:
import '@kern-ux-annex/webc';Use components in your HTML:
<kern-button variant="primary">My First Button</kern-button> <kern-alert variant="success">Welcome to KERN!</kern-alert>Start building! All components are now available and styled with the KERN design system.
Usage
Import all components
import '@kern-ux-annex/webc';Import specific components
import '@kern-ux-annex/webc/components/button/kern-button.js';
import '@kern-ux-annex/webc/components/alert/kern-alert.js';Use in HTML
<kern-button variant="primary" size="large">Click me</kern-button>
<kern-alert variant="success" dismissible>Operation completed!</kern-alert>
<kern-badge variant="warning">New</kern-badge>Use in frameworks
React
import '@kern-ux-annex/webc';
function App() {
return (
<div>
<kern-button variant="primary" onClick={handleClick}>
Click me
</kern-button>
</div>
);
}Vue
<template>
<kern-button variant="primary" @kern-click="handleClick">
Click me
</kern-button>
</template>
<script>
import '@kern-ux-annex/webc';
</script>Storybook Integration
The library includes a comprehensive Storybook setup for component development, testing, and documentation.
🎨 Interactive Component Playground
Storybook provides an interactive environment to explore all 50+ KERN components with live examples, property controls, and usage documentation.
🌗 Theme Support
The Storybook environment includes full KERN design system theme support:
- Light Theme: Default KERN light theme with
data-kern-theme="light" - Dark Theme: KERN dark theme with
data-kern-theme="dark" - Dynamic Theme Switching: Toggle between themes using the Storybook toolbar
- Automatic Theme Attributes: Body element automatically receives appropriate
data-kern-themeattributes - KERN CSS Integration: Complete KERN CSS framework and Fira Sans fonts are automatically loaded
🎯 Features
- Complete Component Coverage: All components with multiple variants and states
- Interactive Controls: Modify component properties in real-time
- Accessibility Testing: Built-in accessibility checks and documentation
- Design System Integration: Automatic KERN CSS and font loading
- Responsive Testing: Test components across different screen sizes
- Code Examples: Copy-paste ready code snippets for each component
📚 Storybook Commands
# Start Storybook development server
npm run storybook
# Build static Storybook for deployment
npm run build-storybook🚀 Accessing Storybook
- Development:
http://localhost:6006(when runningnpm run storybook) - Static Build: Available in
storybook-static/directory after building
Scripts & Commands
The project includes comprehensive npm scripts for all development and deployment tasks:
Development Scripts
# Start development server with hot reload
npm run dev
# Start Storybook for component development
npm run storybook
# Run tests in watch mode
npm run test:watch
# Generate KERN styles from latest CSS
npm run generate:stylesBuild Scripts
# Full production build (library + types + changelog)
npm run build
# Build only the bundled library files
npm run build:lib
# Build only TypeScript declaration files
npm run build:types
# Build static Storybook for deployment
npm run build-storybookAzure Deployment Scripts
# Deploy Storybook to Azure Web App (Linux/macOS)
npm run deploy:azure
# Deploy Storybook to Azure Web App (Windows PowerShell)
npm run deploy:azure-ps
# Prepare deployment package locally
npm run deploy:prepareTesting Scripts
# Run all tests once
npm test
# Run tests in watch mode for development
npm run test:watchPublishing Scripts
# Test publish (dry run) - verify package contents
npm run publish:dry-run
# Publish stable release to NPM
npm run publish:package
# Publish beta version with 'beta' tag
npm run publish:beta
# Publish experimental version with 'next' tag
npm run publish:next
# Publish with full test suite (build + test + publish)
npm run publish:with-tests
# Dry run with full test suite
npm run publish:dry-run-with-testsRelease Management Scripts
# Create new release (interactive)
npm run release
# Bump patch version (1.0.0 → 1.0.1)
npm run release:patch
# Bump minor version (1.0.0 → 1.1.0)
npm run release:minor
# Bump major version (1.0.0 → 2.0.0)
npm run release:majorChangelog Scripts
# Generate complete changelog
npm run changelog:generate
# Update changelog with latest changes
npm run changelog:update
# Add version entry to changelog
npm run changelog:add-versionPreview Scripts
# Preview built application
npm run previewComponent Documentation
kern-button
Interactive button component with multiple variants, icon support, and block layout.
Properties:
variant: 'primary' | 'secondary' | 'tertiary' | 'danger' (default: 'primary')disabled: boolean (default: false)type: 'button' | 'submit' | 'reset' (default: 'button')icon-left: KernIconName - Icon to display on the left sideicon-right: KernIconName - Icon to display on the right sideblock: boolean (default: false) - Full width button
Events:
kern-click: Fired when button is clicked
Example:
<kern-button variant="primary" icon-left="add">Add Item</kern-button>
<kern-button variant="danger" disabled>Disabled Button</kern-button>
<kern-button block>Full Width Button</kern-button>kern-alert
Status and notification messages with multiple variants and dismissible support.
Properties:
variant: 'info' | 'success' | 'warning' | 'danger' (default: 'info')title: string - Alert titledismissible: boolean (default: false)
Events:
kern-dismiss: Fired when alert is dismissed
Slots:
title: Alert title contentdefault: Alert message content
Example:
<kern-alert variant="success" title="Success">Operation completed!</kern-alert>
<kern-alert variant="error" dismissible>Something went wrong</kern-alert>kern-card
Container component with multiple variants and sub-component support.
Properties:
variant: 'default' | 'hug' | 'active' | 'small' | 'large' (default: 'default')max-width: string - Optional maximum width
Events:
kern-card-click: Fired when active variant card is clicked
Sub-components:
kern-card-media: For images and media contentkern-card-header: For card headerskern-card-body: For main card contentkern-card-footer: For card actionskern-card-container: For grouping header/body/footer
Example:
<kern-card variant="active" max-width="400px">
<kern-card-media>
<img src="image.jpg" alt="Card image">
</kern-card-media>
<kern-card-container>
<kern-card-header>
<kern-title>Card Title</kern-title>
</kern-card-header>
<kern-card-body>
<kern-body>Card content goes here</kern-body>
</kern-card-body>
<kern-card-footer>
<kern-button variant="primary">Action</kern-button>
</kern-card-footer>
</kern-card-container>
</kern-card>kern-tabs
Tabbed content navigation with multiple variants and accessibility support.
Properties:
active-tab: string - ID of the currently active tabvariant: 'default' | 'underlined' | 'pills' (default: 'pills')size: 'small' | 'medium' | 'large' (default: 'medium')
Events:
kern-tab-change: Fired when active tab changes
Sub-components:
kern-tab-panel: Individual tab panels withtab-id,tab-label, anddisabledproperties
Example:
<kern-tabs active-tab="tab1" variant="pills">
<kern-tab-panel tab-id="tab1" tab-label="First Tab">
<p>Content for first tab</p>
</kern-tab-panel>
<kern-tab-panel tab-id="tab2" tab-label="Second Tab">
<p>Content for second tab</p>
</kern-tab-panel>
</kern-tabs>kern-input
Text input controls with validation and multiple input types.
Properties:
label: string - Input labelvalue: string - Input valuetype: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search' | 'file' (default: 'text')placeholder: string - Placeholder textdisabled: boolean (default: false)required: boolean (default: false)readonly: boolean (default: false)error-message: string - Error message to displayhelp-text: string - Help text to displayname: string - Form field nameautocomplete: string - Autocomplete attribute
Events:
kern-input: Fired when input value changeskern-focus: Fired when input gains focuskern-blur: Fired when input loses focus
Example:
<kern-input
label="Email Address"
type="email"
required
help-text="We'll never share your email">
</kern-input>kern-table
Complete table system with responsive design and accessibility.
Properties:
caption: string - Table captionsmall: boolean (default: false) - Compact table variantstriped: boolean (default: false) - Alternating row colorsresponsive: boolean (default: false) - Responsive wrapper
Sub-components:
kern-thead,kern-tbody,kern-tfoot: Table sectionskern-tr: Table rowskern-th,kern-td: Table cells
Example:
<kern-table caption="Data Table" striped responsive>
<kern-thead>
<kern-tr>
<kern-th>Name</kern-th>
<kern-th>Email</kern-th>
<kern-th>Role</kern-th>
</kern-tr>
</kern-thead>
<kern-tbody>
<kern-tr>
<kern-td>John Doe</kern-td>
<kern-td>john@example.com</kern-td>
<kern-td>Admin</kern-td>
</kern-tr>
</kern-tbody>
</kern-table>kern-heading
Semantic heading component with KERN design system typography classes using a 1:1 relationship between heading levels and typography sizes.
Properties:
level: 1 | 2 | 3 | 4 | 5 | 6 - REQUIRED - The semantic heading levelsize: 'display' | 'x-large' | 'large' | 'medium' | 'small' - Optional override for default level-size mapping
Default Level-to-Size Mapping:
level="1"→kern-heading-displaylevel="2"→kern-heading-x-largelevel="3"→kern-heading-largelevel="4"→kern-heading-mediumlevel="5"→kern-heading-smalllevel="6"→kern-heading-small
Example:
<!-- Default 1:1 mapping -->
<kern-heading level="1">Display Heading (h1)</kern-heading>
<kern-heading level="2">X-Large Heading (h2)</kern-heading>
<kern-heading level="3">Large Heading (h3)</kern-heading>
<!-- Override with custom size -->
<kern-heading level="3" size="display">h3 with Display styling</kern-heading>
<kern-heading level="1" size="small">h1 with Small styling</kern-heading>kern-body / kern-text
Body text component with KERN design system typography classes. Available as both kern-body and kern-text for semantic flexibility.
Properties:
size: 'large' | 'default' | 'small' - Text size variant (defaults to 'default')bold: boolean - Whether to apply bold font weight (defaults to false)
Available KERN CSS Classes Applied:
- Base:
.kern-body - Size variants:
.kern-body--large,.kern-body--small - Weight variant:
.kern-body--bold
Example:
<!-- Default body text -->
<kern-body>Standard body text with default size and weight.</kern-body>
<!-- Size variants -->
<kern-body size="large">Large body text for emphasis.</kern-body>
<kern-body size="small">Small body text for secondary information.</kern-body>
<!-- Bold text -->
<kern-body bold>Bold body text for emphasis.</kern-body>
<!-- Combined properties -->
<kern-body size="large" bold>Large bold text for strong emphasis.</kern-body>
<!-- Alternative component name -->
<kern-text size="small">Alternative semantic name for body text.</kern-text>Development
Prerequisites
- Node.js 18+ (LTS recommended)
- npm 8+ or yarn 1.22+
- Git for version control
Setup
# Clone the repository
git clone https://gitlab.opencode.de/kern-ux/community/kern-webcomponents-light-kit.git
cd kern-webcomponents-light-kit
# Install dependencies
npm install
# Generate KERN styles and start development server
npm run dev
# Start Storybook for component development
npm run storybookProject Structure
kern-webcomponents-light-kit/
├── examples # Two example projects for plain HTML usage (with Vite) and React usage.
├── .storybook/ # Storybook configuration
│ ├── main.ts # Main Storybook config with KERN CSS imports
│ └── preview.ts # Preview config with theme support
├── src/
│ ├── components/ # All KERN web components
│ │ ├── accordion/ # Component folders with .ts and .stories.ts files
│ │ ├── alert/
│ │ ├── button/
│ │ └── ... # 50+ component directories
│ ├── styles/ # Global styles and CSS utilities
│ │ ├── kern-styles.ts # Generated KERN CSS content
│ │ └── ...
│ └── index.ts # Main entry point - exports all components
├── test/ # Component tests (.test.ts files)
├── scripts/ # Build and automation scripts
│ ├── generate-kern-styles.js # KERN CSS integration
│ ├── generate-changelog.js # Automated changelog
│ ├── publish.js # NPM publishing
│ └── release.js # Version management
├── docs/ # Documentation and guides
├── dist/ # Built library output
└── storybook-static/ # Built Storybook outputDevelopment Workflow
- Component Development: Create/modify components in
src/components/ - Story Creation: Add Storybook stories (
.stories.ts) for component testing - Test Writing: Create comprehensive tests in
test/directory - Documentation: Update component documentation and examples
- Build & Test: Run full build and test suite before committing
Key Development Files
src/index.ts: Main entry point - add new component exports here.storybook/preview.ts: Storybook theme configuration with KERN integrationrollup.config.js: Build configuration for library bundlingweb-test-runner.config.js: Test runner configurationtsconfig.json: TypeScript configuration for developmenttsconfig.build.json: TypeScript configuration for production builds
Adding New Components
- Create component directory:
src/components/my-component/ - Implement component:
my-component.tsextendingKernElement - Add Storybook stories:
my-component.stories.ts - Write tests:
test/my-component.test.ts - Export component: Add to
src/index.ts - Update documentation: Add to README.md component list
Component Development Guidelines
- Extend KernElement: All components should extend the base
KernElementclass - Use KERN CSS: Apply KERN design system classes and tokens from
@kern-ux/native - Follow Lit Patterns: Use Lit decorators, reactive properties, and best practices
- TypeScript Types: Provide complete TypeScript interfaces and JSDoc documentation
- Custom Events: Emit events with
kern-prefix for consistency - CSS Custom Properties: Use CSS variables for theming aligned with KERN tokens
- Accessibility: Ensure ARIA compliance and keyboard navigation support
- Testing: Write comprehensive tests covering properties, events, and accessibility
Testing
The project uses Web Test Runner with Playwright for comprehensive testing across multiple browsers.
Test Configuration
- Framework:
@web/test-runnerwith@open-wc/testing - Browsers: Chromium, Firefox, and WebKit via Playwright
- Coverage: Included in test runs with detailed reporting
- Accessibility: Built-in accessibility testing with
@open-wc/testing
Running Tests
# Run all tests once
npm test
# Run tests in watch mode for development
npm run test:watch
# Run tests with coverage report
npm test -- --coverageTest Structure
- Location: All tests in
test/directory - Naming:
component-name.test.tsformat - Coverage: Tests cover component properties, events, slots, and accessibility
- Examples: Each test file includes comprehensive component testing patterns
Writing Tests
import { fixture, assert } from '@open-wc/testing';
import { html } from 'lit';
import '../src/components/button/kern-button.js';
describe('kern-button', () => {
it('renders with default properties', async () => {
const el = await fixture(html`<kern-button>Test</kern-button>`);
assert.shadowDom.equal(el, '<button class="kern-button">Test</button>');
});
it('emits kern-click event', async () => {
const el = await fixture(html`<kern-button>Test</kern-button>`);
let eventFired = false;
el.addEventListener('kern-click', () => { eventFired = true; });
el.click();
assert.isTrue(eventFired);
});
});Publishing
The library supports automated publishing to NPM with different distribution tags:
# Test publish (dry run)
npm run publish:dry-run
# Publish stable release
npm run publish:package
# Publish beta version
npm run publish:beta
# Publish experimental version
npm run publish:nextFor detailed publishing instructions, see NPM Publishing Guide.
Performance & Bundle Size
- Tree-shakeable: Import only the components you need
- Lightweight: Built with minimal dependencies
- Modern: Leverages native browser APIs for optimal performance
- CSS-in-JS free: Uses native CSS with Shadow DOM for style isolation
Bundle Analysis
The library is designed for optimal tree-shaking. When importing individual components:
// Only bundles the button component
import '@kern-ux-annex/webc/components/button/kern-button.js';Browser Support
Modern browsers that support:
- ES2019+
- Web Components (Custom Elements, Shadow DOM)
- CSS Custom Properties
- Modern browser versions: Chrome 64+, Firefox 63+, Safari 13+, Edge 79+
License
EUPL-1.2 License - see LICENSE.md file for details
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
For more details, see CONTRIBUTING.md.
Design System
This library implements the KERN design system. For design guidelines and specifications, refer to the KERN design documentation.
The library automatically imports the KERN CSS framework and Fira Sans font. All components use KERN design tokens for consistent styling.
Links & Resources
- KERN UX Website: kern-ux.de
- KERN Plain CSS/HTML Kit: GitLab Repository
- KERN Pattern Library: Main Repository
- Issues & Bug Reports: Project Issues
Related Projects
- KERN Plain CSS/HTML Kit - The foundation CSS and HTML examples this library is based on
- KERN Pattern Library - The main KERN design system repository
- KERN UX Community - Join the interdisciplinary community for digital public administration
Made with ❤️ by the KERN UX Community