Web UI Components & Design System
Krewire UI (kui) is a zero-dependency, neo-brutalist ("pop-brutalist") design system and Single-File Component library built natively for the Krewire Go ecosystem.
It combines high-contrast pop visual styling (crisp solid borders, bold offset drop shadows, vibrant emerald and cyan accents) with standard semantic HTML primitives and pure Go compilation.
Component-by-Component Documentation: For dedicated pages, prop specifications, and live
.kiwcode examples for each of the 66 components, explore the Krewire UI Components Catalog.
1. Why Krewire UI Eliminates "Dependency Hell"
In traditional frontend ecosystems (such as Node.js, React, or npm-based toolchains), developers routinely suffer from dependency hell:
- Fragile
node_modulestrees with hundreds of transitive packages. - Breaking changes caused by upstream minor updates.
- Incompatible peer dependencies and bundler lock-in (Webpack, Vite, PostCSS).
Krewire UI eliminates dependency hell by architectural design through four core principles:
- Composable Component Architecture (Go & .kiw):
- Component templates (such as
Button,Modal, orNavbar) can be imported directly as versioned Go modules or used inside.kiwtemplates without runtime bloat. - For developers who wish to customize components locally,
krew ui vendorcopies the.kiwcomponent files directly into your project'scomponents/directory. - Once copied, local components take precedence, giving you complete ownership over markup, layout, and styling.
- Zero NPM / Node.js Runtime Overhead:
- Web output contains zero mandatory JavaScript runtime overhead.
- All
.kiwcomponents compile via the native Go.kiwcompiler with sub-millisecond build speeds.
- Zero Third-Party Go Dependencies:
- In
github.com/krewire/ui/go.mod, the module requires zero external dependencies. - The Go package exports standard library
embed.FSfile trees, allowing you to embed the component templates and CSS directly into single static binaries.
- Strict Separation of Architectural Layers:
- Layer 2 (
pkg/ui): Domain library providing Go interfaces, typed renderers, theme tokens, and programmatic app layout builders. - Layer 5 (
ui): Presentation catalog providing reusable.kiwmarkup templates and the canonical pop-brutalist stylesheet. - Importing backend packages never pulls in unused UI assets.
2. Design Philosophy
- Dual Authoring (Go + .kiw): Components can be authored and used interchangeably as programmatic Go widgets or declarative
.kiwtemplates. - Zero Runtime JavaScript Bloat: Interactive components prioritize native browser primitives (
<details>,<summary>,<dialog>,<form>). Framework-free vanilla JavaScript is used only where native browser events require it (such as closing menus on outside clicks). - High-Contrast Pop-Brutalist Visuals:
- Solid Pop-Borders:
2pxto2.5pxsolid borders for distinct boundary definition. - Hard Offset Shadows:
2px 2px,4px 4px, and6px 6pxdrop shadows without blurry or fuzzy gradients. - Vibrant Accent Palette: Emerald green (
#39D353), high-contrast cyan (#00D1C1), and warning crimson (#FF3B2E). - Full WCAG AA/AAA Compliance: Colors and text contrast ratios pass strict accessibility audits.
- Deterministic Token Cascading:
Styles inherit from single-sourced CSS custom properties. Overriding a token at :root or on a container element instantly cascades down the DOM hierarchy.
3. Getting Started
Method A: Adding the Component Package (Recommended)
Add Krewire UI to your project using krew add:
krew add github.com/krewire/ui
Method B: Using Components in .kiw Templates
Import components directly in your .kiw files:
<script>
import { Button, Card, Navbar } from '@krewire/ui';
</script>
<Card title="Hello World">
<Button variant="primary">Click Me</Button>
</Card>
Method C: Local Source Customization (Opt-in)
To fork and edit individual components locally:
krew ui vendor Button
krew ui vendor Card
Method D: Using Go embed.FS in Backend Applications
For Go backend services that serve components or styles dynamically:
package main
import (
"fmt"
"github.com/krewire/ui/components"
"github.com/krewire/ui/styles"
)
func main() {
// Access embedded filesystem containing all 66 .kiw components
fs := components.FS
// Load a specific component template
buttonTemplate, err := components.Get("Button")
if err != nil {
panic(err)
}
// Access canonical CSS stylesheet
css := styles.CSS
fmt.Printf("Loaded Button template (%d bytes) and CSS (%d bytes)\n", len(buttonTemplate), len(css))
}
Linking the Design System Stylesheet
Include the canonical stylesheet containing design tokens, base resets, and layout primitives in your HTML <head>:
<link rel="stylesheet" href="/styles/krewire-ui.css">
4. Design Tokens System (krewire-ui.css)
Krewire UI defines standardized semantic design tokens using CSS custom properties:
Semantic Colors
:root {
--primary: #39D353; /* Vivid emerald green */
--primary-content: #0B1F3B; /* High-contrast midnight navy text */
--primary-hover: #2ecc50;
--secondary: #00D1C1; /* Bright cyan */
--secondary-content: #0B1F3B;
--accent: #FF3B2E; /* Alert crimson */
--accent-content: #ffffff;
--success: #39D353;
--warning: #ffb703; /* Amber gold */
--error: #FF3B2E; /* Alert red */
--info: #00D1C1; /* Informational cyan */
}
Surfaces & Dark Mode Inversion
:root {
--bg: #FAF8F4; /* Base alabaster cream */
--bg-2: #f2ede4; /* Subtle elevated surface */
--bg-3: #e8e2d5; /* Bordered card container */
--fg: #0B1F3B; /* Primary midnight navy text */
--muted: #57677d; /* Secondary descriptive text */
--border: #0B1F3B; /* Pop-brutalist border color */
}
:root[data-theme="dark"], html[data-theme="dark"], .dark {
--bg: #0B1F3B; /* Midnight navy background */
--bg-2: #112646; /* Elevated dark surface */
--bg-3: #1a3865; /* Dark card background */
--fg: #FAF8F4; /* High-contrast cream text */
--muted: #9ab0ce; /* Muted light text */
--border: #FAF8F4; /* Light pop-brutalist border */
}
Pop-Brutalist Borders & Shadows
:root {
--pop-border: 2.5px solid var(--border);
--pop-border-thin: 2px solid var(--border);
--pop-shadow-sm: 2px 2px 0px var(--border);
--pop-shadow: 4px 4px 0px var(--border);
--pop-shadow-lg: 6px 6px 0px var(--border);
--radius: 10px;
}
:root[data-theme="dark"], html[data-theme="dark"], .dark {
--pop-shadow-sm: 2px 2px 0px var(--primary);
--pop-shadow: 4px 4px 0px var(--primary);
--pop-shadow-lg: 6px 6px 0px var(--primary);
}
Spacing & Typography Scale
- Grid Spacing: Built on a 4px/8px incremental scale (
--ui-space-1: 4px,--ui-space-2: 8px,--ui-space-4: 16px,--ui-space-6: 24px,--ui-space-8: 32px). - Typography Scale:
- Micro / Labels:
--ui-text-xs(11px),--ui-text-sm(13px). - Body:
--ui-text-base(14.5px/0.9rem). - Headings:
--ui-text-lg(17px),--ui-text-xl(20px),--ui-text-2xl(24px),--ui-text-3xl(30px),--ui-text-4xl(36px).
5. Complete 66-Component Catalog
Krewire UI includes 66 Single-File Components divided into 7 functional categories:
5.1 Navigation & Structure
<Navbar />: Main responsive header with brand logo, nav links, and mobile drawer trigger.<NavMenu />: Accessible navigation bar with interactive dropdown support.<Sidebar />: Collapsible sidebar navigation for documentation and dashboard portals.<Breadcrumb />: Hierarchical page breadcrumb navigation.<BreadcrumbItem />: Individual item within a breadcrumb trail.<Tabs />: Accessible content switcher supporting persistent active states.<Pagination />: Numbered pagination bar with next/prev buttons.<Drawer />: Smooth sliding overlay panel for mobile navigation.<Hamburger />: Animated 3-line hamburger menu toggle button.<Brand />: Scalable ecosystem logo and version badge.<Head />: Canonical<head>metadata and stylesheet injector.<Header />: Sectional page banner header.<Footer />: Comprehensive multi-column site footer with copyright and links.
5.2 Actions & Buttons
<Button />: Core interactive button supportingprimary,secondary,accent,outline, andghostvariants.<ButtonGroup />: Grouped button set with connected borders and segment controls.<Dropdown />: Accessible dropdown built on native<details>and<summary>elements.<ActionMenu />: Compact contextual action menu for table rows and card headers.<Link />: Styled hyperlink with underline transitions and target safety.<Toggle />: Interactive toggle button for switching binary states.<ThemeSwitch />: Light/dark mode toggle button with localStorage persistence.<LangSwitch />: Language picker toggle for i18n applications.
5.3 Feedback & Status
<Alert />: Contextual notification banner supportinginfo,success,warning, anderrorstates.<Banner />: Full-width announcement bar with dismiss trigger.<Toast />: Lightweight transient notification toast with auto-hide support.<Badge />: Compact micro-indicator badge with color variants.<Tag />: Removable or selectable keyword tag.<Progress />: Determinate and indeterminate loading bar.<Spinner />: Accessible animated SVG loader spinner.<Skeleton />: Shimmer placeholder for content loading states.<Empty />: Empty-state placeholder with icon, message, and call-to-action button.<Callout />: Bordered informative callout for technical documentation.
5.4 Data Display & Content
<Card />: Elevated container with header, media, body, and footer slots.<Stat />: Metric KPI display with trend direction indicators (up,down,neutral).<Table />: Responsive data table with striped, bordered, and hover states.<Accordion />: Expandable/collapsible content accordion with keyboard navigation.<Collapse />: Single collapsible content container.<Timeline />: Sequential vertical activity event stream.<CodeWindow />: macOS-style window with traffic lights and copy-to-clipboard button.<Terminal />: Compact single-line command preview terminal.<Code />: Inline styled monospace code token.<Avatar />: User profile picture with fallback initials.<Kbd />: Keyboard shortcut visual indicator.<Divider />: Visual horizontal or vertical separator with optional label.<Heading />: Semantic heading wrapper (h1throughh6) with consistent typography.<Text />: Typography wrapper for body text, leads, and muted descriptions.<List />: Semantic styled unordered and ordered list.<Ecosystem />: Interactive grid visualizing the Krewire 10-repository architecture.
5.5 Forms & Inputs
<Form />: Accessible form wrapper with submit handling and method spoofing.<Input />: Standard text input with floating label or inline label.<SearchInput />: Dedicated search box with search icon and clear button.<Select />: Native styled dropdown select.<Textarea />: Multi-line text field with auto-resize support.<Checkbox />: High-contrast accessible checkbox.<Radio />: Single-selection radio button.<Slider />: Range slider with numeric value bubble.
5.6 Overlays & Dialogs
<Modal />: Accessible modal dialog utilizing native<dialog>element.<Popover />: Floating contextual popover container.<Tooltip />: Hover and focus informative tooltip.
5.7 Layout Primitives
<Container />: Fixed-width or responsive centered page container.<Box />: Generic layout box with padding and border tokens.<Flex />: Flexible flexbox layout wrapper.<Grid />: CSS Grid container with configurable columns and gap tokens.<HStack />: Horizontal flex layout with uniform spacing.<VStack />: Vertical flex layout with uniform spacing.<Stack />: Directional stack with configurable gap.<Section />: Full-width semantic page section.<SideMenu />: Navigational drawer menu for administrative sidebars.
6. Deep Dive: Key Components & Code Examples
6.1 Button (Button.kiw)
The <Button /> component handles both standard buttons and link buttons:
<!-- Primary action button -->
<Button variant="primary" size="md">
Deploy Workload
</Button>
<!-- Link styled as button with icon -->
<Button href="/docs" variant="outline" size="sm" icon="๐">
Read Documentation
</Button>
<!-- Destructive action with custom onClick -->
<Button variant="accent" size="sm" onClick="confirmDelete()">
Delete Environment
</Button>
Supported props:
variant:primary,secondary,accent,outline,ghost(default:primary).size:sm,md,lg(default:md).href: When provided, renders an accessible<a>tag styled as a button.icon: Prepend icon or emoji string.iconRight: Append icon or emoji string.disabled: Disables user interaction.
6.2 Card (Card.kiw)
The <Card /> component provides a structured, elevated surface:
<Card title="Database Cluster" subtitle="PostgreSQL 17.2 ยท Production" badge="Healthy">
<div class="space-y-3">
<p>Storage utilization: <strong>42% (84 GB / 200 GB)</strong></p>
<Progress value="42" max="100" />
</div>
<div slot="footer" class="flex justify-end gap-2">
<Button variant="ghost" size="sm">Logs</Button>
<Button variant="outline" size="sm">Backup Now</Button>
</div>
</Card>
6.3 Modal Dialog (Modal.kiw)
Built on the native HTML <dialog> element for robust accessibility:
<!-- Trigger Button -->
<Button variant="primary" onClick="document.getElementById('deploy-modal').showModal()">
Launch Modal
</Button>
<!-- Native Dialog Component -->
<Modal id="deploy-modal" title="Confirm Deployment">
<div slot="body">
<p>Are you sure you want to deploy version <strong>v1.4.0</strong> to production?</p>
</div>
<div slot="actions">
<Button variant="ghost" onClick="document.getElementById('deploy-modal').close()">
Cancel
</Button>
<Button variant="primary" onClick="executeDeploy()">
Confirm & Deploy
</Button>
</div>
</Modal>
Key accessibility features:
- Pressing
Escapeautomatically closes the dialog. - Background backdrop click dismisses the dialog.
- Focus is trapped within the active dialog until closed.
6.4 Metrics & KPI Stat (Stat.kiw)
Displays key numeric statistics with trend arrows:
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<Stat label="Total Requests" value="4.8M" change="+12.4%" trend="up" subtitle="vs last week" />
<Stat label="Avg Latency" value="1.2ms" change="-0.4ms" trend="up" subtitle="p99 response" />
<Stat label="Error Rate" value="0.001%" change="0.0%" trend="neutral" subtitle="Zero downtime" />
</div>
6.5 Code Window & Terminal (CodeWindow.kiw & Terminal.kiw)
Renders macOS-style code blocks with copy buttons:
<Terminal command="krew init --site my-portal" />
<CodeWindow title="main.go" language="go">
package main
import "github.com/krewire/krewire/pkg/web"
func main() {
app := web.New()
app.Get("/", func(c *web.Context) error {
return c.String("Hello from Krewire!")
})
app.Run(":8080")
}
</CodeWindow>
7. Programmatic Go API
For backend services that generate UI dynamically or build server-rendered dashboards in pure Go code, use the Layer 2 pkg/ui library:
package main
import (
"fmt"
"github.com/krewire/krewire/pkg/ui"
)
func main() {
// Initialize default registry with standard Go components
reg := ui.Default()
// Render a Badge component programmatically
html, err := reg.Render("Badge", ui.Badge{
Text: "v0.2.3",
Variant: "primary",
})
if err != nil {
panic(err)
}
fmt.Println(string(html))
}
Composing Layouts with AppBuilder
builder := ui.NewAppBuilder()
builder.SetTitle("Dashboard ยท Krewire")
builder.SetTheme(ui.DarkTheme())
builder.AddHeader(ui.Header{
Brand: "Krewire Cloud",
})
builder.AddCard(ui.Card{
Title: "Cluster Status",
Body: "All 6 worker nodes operational.",
})
pageHTML := builder.Build()
8. Accessibility & Engineering Best Practices
- Semantic Landmark Roles: All structural components (
<Navbar>,<Sidebar>,<Footer>,<Section>) emit standard HTML5 landmarks (<nav>,<aside>,<footer>,<section>). - Zero-JS Dropdowns: Dropdown menus use native
<details>and<summary>elements, remaining functional even when JavaScript is disabled. - Focus Rings: All interactive elements feature a high-contrast focus outline (
outline: 3px solid var(--primary); outline-offset: 2px). - Reduced Motion: All pop animations honor
prefers-reduced-motion: reduce, ensuring smooth experiences for sensitive users. - Pure-Go Compilation: Applications embedding Krewire UI compile with
CGO_ENABLED=0to standalone static binaries.