A luxury Svelte 5 component library featuring a Modern Villain Luxury aesthetic. Built on Onyx Black backgrounds with Royal Purple accents, glass morphism, and neon edges for modern web applications that demand commanding elegance and exceptional user experience.
# npm
npm install @mrintel/villain-ui
# pnpm
pnpm add @mrintel/villain-ui
# yarn
yarn add @mrintel/villain-ui
Note on Imports: All components are exported from the root package (
@mrintel/villain-ui). Category-specific subpath imports (e.g.,@mrintel/villain-ui/buttons) are not provided, as the library is designed for tree-shaking at the component level. Your bundler will automatically include only the components you import.
Install the required peer dependency:
npm install svelte@^5.0.0
Note on Tailwind CSS: The library uses Tailwind CSS v4 internally for styling, but it is not required as a peer dependency. The compiled theme CSS is included in the package. You only need to install Tailwind CSS in your project if you want to extend the library's theme with custom Tailwind utilities or use Tailwind for your own application styling.
Important: The theme CSS is not automatically imported when you use components. You must explicitly import it in your app's entry point to apply the default styles.
Import the theme CSS in your app's entry point (e.g., +layout.svelte in SvelteKit or main.ts in Vite):
import '@mrintel/villain-ui/theme.css';
This explicit import strategy gives you full control over styling and allows you to:
<!-- src/routes/+layout.svelte -->
<script>
import '@mrintel/villain-ui/theme.css';
</script>
<slot />
<script>
import { Button, Card } from '@mrintel/villain-ui';
</script>
<Card padding="lg">
<h1>Welcome to @mrintel/villain-ui</h1>
<p>Build luxury interfaces with ease.</p>
<Button variant="primary">Get Started</Button>
</Card>
Comprehensive icon snippet support across the entire component library for maximum flexibility:
Forms:
iconBefore and iconAfter snippets for flexible positioningiconBefore snippet for visual enhancementiconBefore in options array for rich radio listsicon snippet to override default upload iconButtons & Navigation:
iconBefore and iconAfter snippets for flexible positioningicon in items array for visual breadcrumb trailsprevIcon and nextIcon snippets for custom navigation arrowsiconBefore in tab objects for tabbed navigationData Display:
icon snippet for status indicators (not iconBefore, as it's a simple badge)icon snippet for tagsicon in items array for icon listsOverlays:
iconBefore snippet for custom alert iconsiconBefore snippet for title iconsNavigation:
icon in items arrayicon in items array with structured MenuItem[] interfaceThe library uses three consistent icon patterns:
1. Simple icon snippet - Single icon?: Snippet for components with one icon position:
<Tag>
{#snippet icon()}
<StarIcon class="w-4 h-4" />
{/snippet}
Featured
</Tag>
2. Positional icon snippets - Separate iconBefore/iconAfter snippets for flexible positioning:
<Button>
{#snippet iconAfter()}
<ArrowRightIcon class="w-5 h-5" />
{/snippet}
Next
</Button>
<!-- Or with both icons -->
<LinkButton>
{#snippet iconBefore()}
<HomeIcon class="w-5 h-5" />
{/snippet}
Home
{#snippet iconAfter()}
<ExternalLinkIcon class="w-4 h-4" />
{/snippet}
</LinkButton>
3. Per-item icons - Icons specified in item/option arrays:
<script>
const options = [
{
value: 'option1',
label: 'Option 1',
iconBefore: IconSnippet // Snippet reference
}
];
</script>
<RadioGroup {options} bind:value={selected} />
<Breadcrumbs items={breadcrumbItems} />
w-5 h-5 or w-4 h-4 across your application for visual harmonycurrentColorNavbar and Sidebar components now automatically style active navigation items:
active class to links/buttons for current page indicationcurrentPath prop for automatic active state management (see Layout Best Practices)currentPath works: Components scan for <a> and <button> elements, match their href or data-href attribute against currentPath, and automatically add/remove the active classactive classes take precedence and are never removed by automatic managementcurrentPath becomes falsy, only auto-managed active classes are cleareddata-href attribute to participate in automatic active state (e.g., <button data-href="/action">Action</button>)Automatic Sidebar Positioning - Sidebar now automatically detects Navbar presence and adjusts its top position to start just below the Navbar. Zero configuration needed!
How it works:
data-navbar attribute selector to find the Navbar elementoffsetHeight and dynamically sets its own top style propertyZ-index layering ensures proper visual hierarchy:
z-50 (highest, sits on top)z-40 (below navbar, above content)z-50+ (above everything)Example - Zero Configuration:
<script>
let sidebarOpen = $state(true);
</script>
<!-- Navbar automatically gets data-navbar attribute -->
<Navbar position="sticky" height="md">
{#snippet toggleButton()}
<IconButton variant="ghost" onclick={() => sidebarOpen = !sidebarOpen}>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</IconButton>
{/snippet}
{#snippet logo()}
<span>MyApp</span>
{/snippet}
{#snippet navigation()}
<a href="/">Home</a>
<a href="/about">About</a>
{/snippet}
{#snippet actions()}
<Button variant="primary">Sign In</Button>
{/snippet}
</Navbar>
<!-- Sidebar automatically detects Navbar and positions below it -->
<Sidebar bind:open={sidebarOpen} side="left" width="md">
<!-- Sidebar content -->
</Sidebar>
<!-- No manual margin-top needed on Sidebar! -->
Responsive behavior: The Sidebar's positioning updates automatically when the Navbar height changes (e.g., responsive breakpoints, content changes). This ensures consistent layout across all screen sizes.
Button - Primary interactive element with variants
<script>
import { Button } from '@mrintel/villain-ui';
</script>
<Button variant="primary" size="md">Primary Button</Button>
<Button variant="secondary" size="md">Secondary Button</Button>
<Button variant="ghost" size="sm">Ghost Button</Button>
<Button variant="primary" size="lg" disabled>Disabled</Button>
<!-- Simple icon usage -->
<Button variant="primary">
{#snippet iconBefore()}
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
{/snippet}
Add Item
</Button>
<!-- Icon after text -->
<Button variant="secondary">
Download
{#snippet iconAfter()}
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
{/snippet}
</Button>
<!-- Advanced: Different icons before and after -->
<Button variant="primary">
{#snippet iconBefore()}
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
{/snippet}
Upload Photo
{#snippet iconAfter()}
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
{/snippet}
</Button>
IconButton - Compact button for icon-only interactions
<script>
import { IconButton } from '@mrintel/villain-ui';
</script>
<IconButton variant="primary" size="md" ariaLabel="Settings">
<SettingsIcon />
</IconButton>
Props:
variant?: 'primary' | 'secondary' | 'ghost' - Button style variantsize?: 'sm' | 'md' | 'lg' - Button sizeariaLabel: string - Accessibility label (required for screen readers)disabled?: boolean - Disable button interactionButtonGroup - Group related buttons together
<script>
import { ButtonGroup, Button } from '@mrintel/villain-ui';
</script>
<ButtonGroup>
<Button variant="secondary">Left</Button>
<Button variant="secondary">Center</Button>
<Button variant="secondary">Right</Button>
</ButtonGroup>
LinkButton - Button styled as link
<script>
import { LinkButton } from '@mrintel/villain-ui';
</script>
<LinkButton href="/docs" variant="primary">View Documentation</LinkButton>
Icon Examples:
<!-- LinkButton with icon before text -->
<LinkButton href="/docs" variant="primary">
{#snippet iconBefore()}
<BookOpenIcon class="w-5 h-5" />
{/snippet}
View Documentation
</LinkButton>
<!-- LinkButton with icon after text -->
<LinkButton href="/download" variant="secondary">
Download
{#snippet iconAfter()}
<DownloadIcon class="w-5 h-5" />
{/snippet}
</LinkButton>
<!-- LinkButton with different icons before and after -->
<LinkButton href="/external" variant="ghost" target="_blank">
{#snippet iconBefore()}
<ExternalLinkIcon class="w-4 h-4" />
{/snippet}
External Link
{#snippet iconAfter()}
<ArrowRightIcon class="w-4 h-4" />
{/snippet}
</LinkButton>
FloatingActionButton - Prominent floating action button
<script>
import { FloatingActionButton } from '@mrintel/villain-ui';
</script>
<FloatingActionButton
position="bottom-right"
ariaLabel="Create new item"
onclick={() => console.log('FAB clicked')}
>
<PlusIcon />
</FloatingActionButton>
Props:
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' - FAB position on screenariaLabel: string - Accessibility label (required for screen readers)onclick?: () => void - Click handlerdisabled?: boolean - Disable button interactionInput - Text input with label and error states
<script>
import { Input } from '@mrintel/villain-ui';
let email = $state('');
let hasError = $state(false);
</script>
<Input
type="email"
label="Email Address"
placeholder="[email protected]"
bind:value={email}
error={hasError}
/>
Icon Examples:
<!-- Input with icon before (search) -->
<Input
type="text"
label="Search"
placeholder="Search..."
bind:value={searchQuery}
>
{#snippet iconBefore()}
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
{/snippet}
</Input>
<!-- Input with icon after (password visibility toggle) -->
<Input
type="password"
label="Password"
bind:value={password}
>
{#snippet iconAfter()}
<button onclick={togglePasswordVisibility}>
<EyeIcon class="w-5 h-5" />
</button>
{/snippet}
</Input>
<!-- Input with email icon -->
<Input
type="email"
label="Email"
bind:value={email}
>
{#snippet iconBefore()}
<MailIcon class="w-5 h-5" />
{/snippet}
</Input>
Textarea - Multi-line text input
<script>
import { Textarea } from '@mrintel/villain-ui';
let comment = $state('');
</script>
<Textarea
label="Comment"
placeholder="Enter your comment..."
rows={5}
bind:value={comment}
/>
Icon Example:
<Textarea
label="Message"
rows={5}
bind:value={message}
>
{#snippet iconBefore()}
<MessageIcon class="w-5 h-5" />
{/snippet}
</Textarea>
Note: Textarea only supports iconBefore snippet, positioned at top-left of the text area.
Select - Dropdown selection
<script>
import { Select } from '@mrintel/villain-ui';
let selected = $state('');
const options = [
{ value: 'option1', label: 'Option 1' },
{ value: 'option2', label: 'Option 2' },
{ value: 'option3', label: 'Option 3' }
];
</script>
<Select label="Choose an option" {options} bind:value={selected} />
Icon Example:
<Select
label="Country"
{options}
bind:value={selectedCountry}
>
{#snippet iconBefore()}
<GlobeIcon class="w-5 h-5" />
{/snippet}
</Select>
Note: Select only supports iconBefore snippet, positioned at the left side with automatic padding.
Checkbox - Boolean selection
<script>
import { Checkbox } from '@mrintel/villain-ui';
let accepted = $state(false);
</script>
<Checkbox label="I accept the terms and conditions" bind:checked={accepted} />
Icon Example:
<Checkbox bind:checked={accepted}>
{#snippet iconBefore()}
<ShieldCheckIcon class="w-4 h-4" />
{/snippet}
I accept the terms and conditions
</Checkbox>
Switch - Toggle switch
<script>
import { Switch } from '@mrintel/villain-ui';
let enabled = $state(false);
</script>
<Switch label="Enable notifications" bind:checked={enabled} />
Icon Example:
<Switch bind:checked={darkMode}>
{#snippet iconBefore()}
<MoonIcon class="w-4 h-4" />
{/snippet}
Dark Mode
</Switch>
RadioGroup - Single selection from multiple options
<script>
import { RadioGroup } from '@mrintel/villain-ui';
let selected = $state('');
const options = [
{ value: 'small', label: 'Small' },
{ value: 'medium', label: 'Medium' },
{ value: 'large', label: 'Large' }
];
</script>
<RadioGroup label="Select size" {options} bind:value={selected} />
Icon Example:
<script>
import { RadioGroup } from '@mrintel/villain-ui';
import { CreditCardIcon, PayPalIcon } from 'your-icon-library';
const options = [
{
value: 'card',
label: 'Credit Card',
iconBefore: CreditCardIcon // Snippet reference
},
{
value: 'paypal',
label: 'PayPal',
iconBefore: PayPalIcon // Snippet reference
}
];
</script>
<RadioGroup
label="Payment Method"
{options}
bind:value={paymentMethod}
/>
RangeSlider - Numeric range selection
<script>
import { RangeSlider } from '@mrintel/villain-ui';
let volume = $state(50);
</script>
<RangeSlider label="Volume" min={0} max={100} bind:value={volume} />
FileUpload - File selection with drag & drop
<script>
import { FileUpload } from '@mrintel/villain-ui';
function handleUpload(files) {
console.log('Files:', files);
}
</script>
<FileUpload
accept="image/*"
multiple
onchange={handleUpload}
label="Upload Images"
/>
Icon Example:
<FileUpload
bind:files={uploadedFiles}
accept="image/*"
>
{#snippet icon()}
<CloudUploadIcon class="w-8 h-8" />
{/snippet}
</FileUpload>
Note: FileUpload uses a simple icon snippet (not iconBefore) to replace the default upload icon.
InputGroup - Grouped input with addons
<script>
import { InputGroup } from '@mrintel/villain-ui';
</script>
<InputGroup>
{#snippet prepend()}
https://
{/snippet}
<input type="text" placeholder="example.com" />
{#snippet append()}
.com
{/snippet}
</InputGroup>
DatePicker - Date input with native date picker
<script>
import { DatePicker } from '@mrintel/villain-ui';
let selectedDate = $state('');
</script>
<DatePicker
label="Select Date"
bind:value={selectedDate}
min="2024-01-01"
max="2024-12-31"
/>
Props:
value?: string - Selected date in YYYY-MM-DD format (bindable)label?: string - Input labelmin?: string - Minimum selectable datemax?: string - Maximum selectable dateplaceholder?: string - Placeholder textdisabled?: boolean - Disable date selectionerror?: boolean - Show error stateclass?: string - Additional CSS classesTimePicker - Time input with native time picker
<script>
import { TimePicker } from '@mrintel/villain-ui';
let selectedTime = $state('');
</script>
<TimePicker
label="Select Time"
bind:value={selectedTime}
step={900}
/>
Props:
value?: string - Selected time in HH:MM format (bindable)label?: string - Input labelmin?: string - Minimum selectable timemax?: string - Maximum selectable timestep?: number - Time interval in seconds (e.g., 900 = 15 minutes)placeholder?: string - Placeholder textdisabled?: boolean - Disable time selectionerror?: boolean - Show error stateclass?: string - Additional CSS classesDateTimePicker - Combined date and time input
<script>
import { DateTimePicker } from '@mrintel/villain-ui';
let selectedDateTime = $state('');
</script>
<DateTimePicker
label="Select Date & Time"
bind:value={selectedDateTime}
min="2024-01-01T00:00"
max="2024-12-31T23:59"
/>
Props:
value?: string - Selected date-time in ISO format (bindable)label?: string - Input labelmin?: string - Minimum selectable date-timemax?: string - Maximum selectable date-timestep?: number - Time interval in secondsplaceholder?: string - Placeholder textdisabled?: boolean - Disable date-time selectionerror?: boolean - Show error stateclass?: string - Additional CSS classesCard - Content container with optional header and footer
<script>
import { Card } from '@mrintel/villain-ui';
</script>
<Card padding="lg" hoverable>
{#snippet header()}
<h2>Card Title</h2>
{/snippet}
<p>Card content goes here with beautiful glass morphism effect.</p>
{#snippet footer()}
<Button variant="primary">Action</Button>
{/snippet}
</Card>
<!-- Card as a link with lift effect and icon -->
<Card href="/features" class="hover-lift" padding="lg">
{#snippet iconBefore()}
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
{/snippet}
<h3>Feature Name</h3>
<p>Clickable card with hover lift effect.</p>
</Card>
Props:
href?: string - Makes the card a clickable link (renders as <a> tag)target?: string - Link target attribute (e.g., '_blank')rel?: string - Link rel attribute (defaults to 'noopener noreferrer' for target='_blank')padding?: 'none' | 'sm' | 'md' | 'lg' - Internal padding (default: 'md')iconBefore?: Snippet - Optional icon displayed with .card-icon utilityheader?: Snippet - Optional header contentfooter?: Snippet - Optional footer contentchildren?: Snippet - Main card contentclass?: string - Additional CSS classesNote: For clickable cards with hover effects, use href to make the card a link and add class="hover-lift" to enable the lift animation. The iconBefore snippet uses the .card-icon utility class for centered, accent-colored icon display.
Panel - Simple content panel
<script>
import { Panel } from '@mrintel/villain-ui';
</script>
<!-- Recommended: Use variant prop for styling -->
<Panel variant="glass" padding="lg">
<p>Enhanced glass morphism panel</p>
</Panel>
<!-- Default panel with basic glass styling -->
<Panel>
<p>Panel content with default styling</p>
</Panel>
<!-- Legacy: glass prop (deprecated, use variant='glass' instead) -->
<Panel glass={false}>
<p>Solid background panel (backwards compatible)</p>
</Panel>
Panel Props:
variant?: 'default' | 'glass' - Primary styling selector. Use 'glass' for enhanced glass morphism with accent glow.padding?: 'none' | 'sm' | 'md' | 'lg' - Internal padding (default: 'md')rounded?: boolean - Apply rounded corners (default: true)glass?: boolean - Deprecated. Use variant='glass' instead. Only affects variant='default' for backwards compatibility.class?: string - Additional CSS classesGrid - Responsive grid layout
<script>
import { Grid, Card } from '@mrintel/villain-ui';
</script>
<Grid columns={3} gap="lg">
<Card>Item 1</Card>
<Card>Item 2</Card>
<Card>Item 3</Card>
</Grid>
Container - Centered content container
<script>
import { Container } from '@mrintel/villain-ui';
</script>
<Container maxWidth="lg">
<h1>Centered Content</h1>
</Container>
SectionHeader - Section heading with divider
<script>
import { SectionHeader } from '@mrintel/villain-ui';
</script>
<SectionHeader title="Features" subtitle="What makes us different" />
Divider - Visual separator
<script>
import { Divider } from '@mrintel/villain-ui';
</script>
<Divider />
<Divider orientation="vertical" />
Navbar - Top navigation bar
<script>
import { Navbar, Button, IconButton } from '@mrintel/villain-ui';
import { page } from '$app/stores';
let sidebarOpen = $state(false);
let currentPath = $derived($page.url.pathname);
</script>
<Navbar {currentPath}>
{#snippet toggleButton()}
<IconButton variant="ghost" size="sm" onclick={() => sidebarOpen = !sidebarOpen}>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</IconButton>
{/snippet}
{#snippet logo()}
<span style="color: var(--color-accent)">MyApp</span>
{/snippet}
{#snippet navigation()}
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
{/snippet}
{#snippet actions()}
<Button variant="primary">Sign In</Button>
{/snippet}
</Navbar>
Props:
position?: 'sticky' | 'fixed' - Navbar positioning (default: 'sticky')height?: 'sm' | 'md' | 'lg' - Navbar height (default: 'md')navigationAlign?: 'left' | 'center' - Navigation alignment (default: 'center')toggleButton?: Snippet - Toggle button slot (typically for sidebar/mobile menu)logo?: Snippet - Logo content snippetnavigation?: Snippet - Primary navigation links slotactions?: Snippet - Action buttons or profile controls slotchildren?: Snippet - Fallback navigation content (used if navigation not provided)currentPath?: string - Current route path for automatic active state highlightingNote: The currentPath prop enables automatic active state management. Links matching the current path will receive the active class automatically.
Sidebar - Side navigation with collapsible state
<script>
import { Sidebar } from '@mrintel/villain-ui';
import { page } from '$app/stores';
let open = $state(true);
let currentPath = $derived($page.url.pathname);
</script>
<Sidebar bind:open {currentPath}>
{#snippet header()}
<div>App Name</div>
{/snippet}
<!-- Recommended markup pattern for predictable collapsed behavior -->
<a href="/dashboard">
<span class="sidebar-item-icon">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
</span>
<span class="sidebar-item-label">Dashboard</span>
</a>
<a href="/settings">
<span class="sidebar-item-icon">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</span>
<span class="sidebar-item-label">Settings</span>
</a>
<!-- Items without icons will show first letter in collapsed mode -->
<a href="/profile">
<span class="sidebar-item-label">Profile</span>
</a>
</Sidebar>
Props:
open?: boolean (bindable) - Sidebar open/collapsed state (default: true)side?: 'left' | 'right' - Sidebar position (default: 'left')width?: 'sm' | 'md' | 'lg' - Sidebar width when open (default: 'md')header?: Snippet - Header content snippetchildren?: Snippet - Sidebar navigation contentcurrentPath?: string - Current route path for automatic active state highlightingCollapsed Mode Behavior:
.sidebar-item-icon will show the icon centered when collapsed.sidebar-item-label (or text content) in a circular badge.sidebar-item-icon and .sidebar-item-label classes for predictable behaviorcurrentPath?: string - Current route path for automatic active state highlightingCollapsed State Behavior:
When open={false}, the sidebar automatically adapts its display:
1.5rem) with text hiddenThe component automatically detects icons by looking for <svg>, [class*="icon"], or [data-icon] elements. All transitions use smooth animations with var(--ease-luxe).
Active State Management
Navigation components (Navbar, Sidebar) support automatic active state highlighting via the currentPath prop. Pass the current route path, and the component will automatically add the active class to matching links and buttons based on href or data-href attributes. This eliminates manual active class management.
Example:
<script>
import { page } from '$app/stores'; // SvelteKit
let currentPath = $derived($page.url.pathname);
</script>
<Navbar {currentPath}>
<a href="/">Home</a>
<a href="/about">About</a>
</Navbar>
The component matches exact paths and nested routes (e.g., /buttons matches /buttons/icon-button).
Tabs - Tabbed interface
<script>
import { Tabs } from '@mrintel/villain-ui';
let activeTab = $state('tab1');
const tabs = [
{
id: 'tab1',
label: 'Overview',
iconBefore: OverviewIcon // Snippet reference
},
{ id: 'tab2', label: 'Analytics' },
{ id: 'tab3', label: 'Reports' }
];
</script>
<Tabs {tabs} bind:activeTab ontabchange={(newTab) => console.log('Tab changed:', newTab)}>
{#if activeTab === 'tab1'}
<div>Overview content</div>
{:else if activeTab === 'tab2'}
<div>Analytics content</div>
{:else}
<div>Reports content</div>
{/if}
</Tabs>
Keyboard Navigation:
Accessibility Features:
role="tablist", role="tab", aria-selected, aria-disabledtabindex="0")Breadcrumbs - Navigation breadcrumb trail
<script>
import { Breadcrumbs } from '@mrintel/villain-ui';
const items = [
{ label: 'Home', href: '/' },
{ label: 'Products', href: '/products' },
{ label: 'Category', href: '/products/category' },
{ label: 'Item' }
];
</script>
<Breadcrumbs {items} />
Icon Example:
<script>
import { Breadcrumbs } from '@mrintel/villain-ui';
import { HomeIcon, FolderIcon, DocumentIcon } from 'your-icon-library';
const items = [
{
label: 'Home',
href: '/',
icon: HomeIcon // Snippet reference
},
{
label: 'Projects',
href: '/projects',
icon: FolderIcon // Snippet reference
},
{
label: 'Document',
icon: DocumentIcon // Snippet reference
}
];
</script>
<Breadcrumbs {items} />
Menu - Vertical navigation menu
<script>
import { Menu } from '@mrintel/villain-ui';
const items = [
{
id: 'dashboard',
label: 'Dashboard',
icon: DashboardIcon, // Snippet reference
onclick: () => goto('/dashboard')
},
{
id: 'settings',
label: 'Settings',
icon: SettingsIcon, // Snippet reference
onclick: () => goto('/settings')
}
];
</script>
<Menu {items} />
Props:
items?: MenuItem[] - Array of menu itemschildren?: Snippet - Alternative to items array for custom contentMenuItem Interface:
id: string - Unique identifierlabel: string - Display texticon?: Snippet - Optional icon snippet (not iconBefore)disabled?: boolean - Disable itemonclick?: () => void - Click handlerKeyboard Navigation:
Accessibility Features:
role="menu", role="menuitem"DropdownMenu - Dropdown menu with items
<script>
import { DropdownMenu, Button } from '@mrintel/villain-ui';
import { EditIcon, TrashIcon } from 'your-icon-library';
const items = [
{
id: 'edit',
label: 'Edit',
icon: EditIcon, // Snippet reference
onclick: () => console.log('Edit')
},
{
id: 'delete',
label: 'Delete',
icon: TrashIcon, // Snippet reference
onclick: () => console.log('Delete'),
disabled: false
}
];
</script>
<DropdownMenu {items}>
{#snippet trigger()}
<Button>Options</Button>
{/snippet}
</DropdownMenu>
Props:
items: MenuItem[] - Array of menu itemsopen?: boolean (bindable) - Dropdown open stateplacement?: 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' - Menu positiontrigger?: Snippet - Trigger button contentMenuItem Interface:
id: string - Unique identifierlabel: string - Display texticon?: Snippet - Optional icon snippetdisabled?: boolean - Disable itemonclick?: () => void - Click handlerKeyboard Navigation:
Accessibility Features:
role="menu", role="menuitem", aria-haspopup, aria-expanded, aria-controlsContextMenu - Right-click context menu
<script>
import { ContextMenu } from '@mrintel/villain-ui';
import { CopyIcon, PasteIcon } from 'your-icon-library';
const items = [
{
id: 'copy',
label: 'Copy',
icon: CopyIcon, // Snippet reference
onclick: () => console.log('Copy')
},
{
id: 'paste',
label: 'Paste',
icon: PasteIcon, // Snippet reference
onclick: () => console.log('Paste')
}
];
</script>
<ContextMenu {items}>
{#snippet trigger()}
<div>Right click me</div>
{/snippet}
</ContextMenu>
Props:
items: MenuItem[] - Array of menu itemsopen?: boolean (bindable) - Context menu open statex?: number (bindable) - Menu X positiony?: number (bindable) - Menu Y positiontrigger?: Snippet - Content that triggers context menu on right-clickMenuItem Interface:
id: string - Unique identifierlabel: string - Display texticon?: Snippet - Optional icon snippetdisabled?: boolean - Disable itemonclick?: () => void - Click handlerKeyboard Navigation:
Accessibility Features:
role="menu", role="menuitem", aria-haspopupModal - Modal dialog with backdrop
<script>
import { Modal, Button } from '@mrintel/villain-ui';
let open = $state(false);
</script>
<Button onclick={() => open = true}>Open Modal</Button>
<Modal bind:open title="Confirm Action">
<p>Are you sure you want to proceed?</p>
{#snippet footer()}
<Button variant="ghost" onclick={() => open = false}>Cancel</Button>
<Button variant="primary" onclick={() => open = false}>Confirm</Button>
{/snippet}
</Modal>
Icon Example:
<script>
import { Modal, Button } from '@mrintel/villain-ui';
import { ExclamationTriangleIcon } from 'your-icon-library';
let open = $state(false);
</script>
<Button onclick={() => open = true}>Delete Item</Button>
<Modal bind:open title="Confirm Deletion">
{#snippet iconBefore()}
<ExclamationTriangleIcon class="w-6 h-6 text-error" />
{/snippet}
<p>Are you sure you want to delete this item? This action cannot be undone.</p>
{#snippet footer()}
<Button variant="ghost" onclick={() => open = false}>Cancel</Button>
<Button variant="primary" onclick={() => { deleteItem(); open = false; }}>Delete</Button>
{/snippet}
</Modal>
Props:
open?: boolean (bindable) - Modal open statetitle?: string - Modal title texticonBefore?: Snippet - Optional icon displayed before titlecloseOnEscape?: boolean - Close modal on Escape key (default: true)closeOnBackdrop?: boolean - Close modal on backdrop click (default: true)footer?: Snippet - Optional footer contentchildren?: Snippet - Main modal contentAccessibility Features:
closeOnEscape=true)role="dialog", aria-modal="true", aria-labelledbyAlert - Alert message with variants
<script>
import { Alert } from '@mrintel/villain-ui';
</script>
<Alert variant="success" title="Success">
Operation completed successfully!
</Alert>
<Alert variant="warning" title="Warning">
Please review your changes.
</Alert>
<Alert variant="error" title="Error">
An error occurred.
</Alert>
<!-- With custom icon -->
<Alert variant="info" title="Custom Icon">
{#snippet iconBefore()}
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 12a2 2 0 100-4 2 2 0 000 4z"/>
<path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/>
</svg>
{/snippet}
This alert uses a custom icon snippet.
</Alert>
Props:
variant?: 'success' | 'warning' | 'error' | 'info' - Alert style varianttitle: string - Alert title texticonBefore?: Snippet - Optional custom icon (overrides default variant icon)dismissible?: boolean - Show close button (default: false)onclose?: () => void - Callback when alert is dismissedchildren?: Snippet - Alert contentAccessibility Features:
role="status" (info/success) or role="alert" (warning/error)aria-live: "polite" (info/success/warning) or "assertive" (error)aria-label="Dismiss alert"Spinner - Loading spinner
<script>
import { Spinner } from '@mrintel/villain-ui';
</script>
<Spinner size="lg" />
Tooltip - Hover tooltip
<script>
import { Tooltip } from '@mrintel/villain-ui';
</script>
<Tooltip content="This is a helpful tip" position="top">
<Button>Hover me</Button>
</Tooltip>
ProgressBar - Progress indicator
<script>
import { ProgressBar } from '@mrintel/villain-ui';
let progress = $state(45);
</script>
<ProgressBar value={progress} max={100} showLabel />
SkeletonLoader - Content loading placeholder
<script>
import { SkeletonLoader } from '@mrintel/villain-ui';
</script>
<SkeletonLoader variant="text" count={3} />
<SkeletonLoader variant="circle" width="60px" height="60px" />
<SkeletonLoader variant="rectangle" width="100%" height="200px" />
Toast - Notification toast
<script>
import { Toast } from '@mrintel/villain-ui';
let show = $state(false);
</script>
<Toast bind:show variant="success" duration={3000}>
Changes saved successfully!
</Toast>
Icon Examples:
<script>
import { Toast } from '@mrintel/villain-ui';
import { CheckCircleIcon, XCircleIcon, InformationCircleIcon } from 'your-icon-library';
let showSuccess = $state(false);
let showError = $state(false);
let showInfo = $state(false);
</script>
<!-- Success toast with custom icon -->
<Toast bind:show={showSuccess} variant="success" duration={3000}>
{#snippet iconBefore()}
<CheckCircleIcon class="w-5 h-5" />
{/snippet}
Changes saved successfully!
</Toast>
<!-- Error toast with custom icon -->
<Toast bind:show={showError} variant="error" duration={5000}>
{#snippet iconBefore()}
<XCircleIcon class="w-5 h-5" />
{/snippet}
Failed to save changes. Please try again.
</Toast>
<!-- Info toast with custom icon -->
<Toast bind:show={showInfo} variant="info">
{#snippet iconBefore()}
<InformationCircleIcon class="w-5 h-5" />
{/snippet}
New features available! Check them out.
</Toast>
Drawer - Slide-out drawer panel
<script>
import { Drawer, Button } from '@mrintel/villain-ui';
let open = $state(false);
</script>
<Button onclick={() => open = true}>Open Drawer</Button>
<Drawer bind:open position="right">
<h2>Drawer Content</h2>
<p>This slides in from the side.</p>
</Drawer>
Icon Example:
<script>
import { Drawer, Button } from '@mrintel/villain-ui';
import { Cog6ToothIcon } from 'your-icon-library';
let open = $state(false);
</script>
<Button onclick={() => open = true}>Open Settings</Button>
<Drawer bind:open position="right" title="Settings">
{#snippet iconBefore()}
<Cog6ToothIcon class="w-6 h-6" />
{/snippet}
<div class="space-y-4">
<h3>Application Settings</h3>
<p>Configure your preferences here.</p>
<!-- Settings content -->
</div>
</Drawer>
Props:
open?: boolean (bindable) - Drawer open stateside?: 'left' | 'right' | 'top' | 'bottom' - Drawer slide-in position (default: 'right')title?: string - Drawer title texticonBefore?: Snippet - Optional icon displayed before titlecloseOnEscape?: boolean - Close drawer on Escape key (default: true)closeOnBackdrop?: boolean - Close drawer on backdrop click (default: true)children?: Snippet - Main drawer contentAccessibility Features:
closeOnEscape=true)role="dialog", aria-modal="true", aria-labelledbyPopover - Popover content
<script>
import { Popover } from '@mrintel/villain-ui';
</script>
<Popover>
{#snippet trigger()}
<Button>Click me</Button>
{/snippet}
{#snippet content()}
<div>Popover content here</div>
{/snippet}
</Popover>
Dropdown - Generic dropdown container
<script>
import { Dropdown } from '@mrintel/villain-ui';
</script>
<Dropdown trigger="Select Option">
<a href="#">Option 1</a>
<a href="#">Option 2</a>
<a href="#">Option 3</a>
</Dropdown>
CommandPalette - Command palette with fuzzy search
<script>
import { CommandPalette } from '@mrintel/villain-ui';
let open = $state(false);
const commands = [
{ id: '1', label: 'New File', onSelect: () => console.log('New File') },
{ id: '2', label: 'Open Settings', onSelect: () => console.log('Settings') },
{ id: '3', label: 'Search Files', onSelect: () => console.log('Search') }
];
</script>
<CommandPalette bind:open {commands} placeholder="Search commands..." />
Keyboard Navigation:
Accessibility Features:
role="combobox", aria-expanded, aria-haspopup, aria-controls, aria-activedescendantHeading - Semantic heading levels
<script>
import { Heading } from '@mrintel/villain-ui';
</script>
<Heading level={1}>Main Title</Heading>
<Heading level={2}>Section Title</Heading>
<Heading level={3}>Subsection</Heading>
<!-- Gradient variant for hero and section titles -->
<Heading level={1} variant="gradient">Hero Title with Gradient</Heading>
<Heading level={2} variant="gradient" glow>Section with Gradient and Glow</Heading>
Props:
level: 1 | 2 | 3 | 4 | 5 | 6 - Semantic heading level (required)variant?: 'gradient' - Apply gradient styling using the .text-gradient utilityglow?: boolean - Add text glow effect (works well with gradient variant)class?: string - Additional CSS classesNote: The gradient variant applies the .text-gradient utility class, creating a purple-to-soft-purple gradient effect. Combine with glow for enhanced visual impact on hero sections.
Text - Text with variants
<script>
import { Text } from '@mrintel/villain-ui';
</script>
<Text variant="body">Regular body text</Text>
<Text variant="caption">Caption text</Text>
<Text variant="muted">Muted text</Text>
Code - Inline code
<script>
import { Code } from '@mrintel/villain-ui';
</script>
<p>Install with <Code>npm install @mrintel/villain-ui</Code></p>
Table - Data table with sorting, filtering, and custom rendering
<script>
import { Table, type TableColumn, type SortDirection } from '@mrintel/villain-ui';
const columns: TableColumn[] = [
{ key: 'name', label: 'Name', sortable: true },
{ key: 'email', label: 'Email', sortable: true },
{ key: 'role', label: 'Role', align: 'center' },
{
key: 'status',
label: 'Status',
render: (value) => `<span class="badge-${value}">${value}</span>`
}
];
let allData = [
{ name: 'John Doe', email: '[email protected]', role: 'Admin', status: 'active' },
{ name: 'Jane Smith', email: '[email protected]', role: 'User', status: 'active' },
{ name: 'Bob Johnson', email: '[email protected]', role: 'User', status: 'inactive' }
];
let data = $state([...allData]);
let searchQuery = $state('');
// User-defined filter function
const filterFn = (row: Record<string, any>) => {
if (!searchQuery) return true;
const query = searchQuery.toLowerCase();
return (
row.name.toLowerCase().includes(query) ||
row.email.toLowerCase().includes(query) ||
row.role.toLowerCase().includes(query)
);
};
// User-defined sort handler
function handleSort(columnKey: string, direction: SortDirection) {
if (!direction) {
data = [...allData];
return;
}
data = [...data].sort((a, b) => {
const aVal = a[columnKey];
const bVal = b[columnKey];
const modifier = direction === 'asc' ? 1 : -1;
return aVal > bVal ? modifier : aVal < bVal ? -modifier : 0;
});
}
// User-defined row click handler
function handleRowClick(row: Record<string, any>) {
console.log('Clicked row:', row);
}
</script>
<input type="text" bind:value={searchQuery} placeholder="Search..." />
<Table
{columns}
{data}
{filterFn}
onSort={handleSort}
onRowClick={handleRowClick}
loading={isLoading}
loadingMessage="Loading data..."
emptyMessage="No results found"
stickyHeader
hoverable
striped
/>
<!-- Custom empty state -->
<Table {columns} {data} striped>
{#snippet emptyState()}
<div>
<h3>No data yet</h3>
<p>Add your first item to get started</p>
<button>Add Item</button>
</div>
{/snippet}
</Table>
<!-- Manual markup mode still supported -->
<Table striped hoverable>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>[email protected]</td>
</tr>
</tbody>
</Table>
<!-- Table Features -->
Props:
- filterFn: (row) => boolean - User-defined filter/search function
- onSort: (columnKey, direction) => void - Sort callback
- onRowClick: (row) => void - Row click callback
- loading: boolean - Show loading spinner
- loadingMessage: string - Custom loading text
- emptyMessage: string - Text when no data
- emptyState: Snippet - Custom empty state component
- stickyHeader: boolean - Sticky table header on scroll
- striped/hoverable/compact: Visual variants
Pagination - Page navigation
<script>
import { Pagination } from '@mrintel/villain-ui';
let currentPage = $state(1);
const totalPages = 10;
</script>
<Pagination bind:currentPage {totalPages} />
Icon Examples:
<script>
import { Pagination } from '@mrintel/villain-ui';
import { ChevronLeftIcon, ChevronRightIcon } from 'your-icon-library';
let currentPage = $state(1);
</script>
<!-- Pagination with custom prev/next icons -->
<Pagination
{currentPage}
totalPages={10}
onPageChange={(page) => currentPage = page}
>
{#snippet prevIcon()}
<ChevronLeftIcon class="w-5 h-5" />
{/snippet}
{#snippet nextIcon()}
<ChevronRightIcon class="w-5 h-5" />
{/snippet}
</Pagination>
<!-- Icon-only pagination (no "Previous"/"Next" text) -->
<Pagination
{currentPage}
totalPages={10}
showLabels={false}
onPageChange={(page) => currentPage = page}
>
{#snippet prevIcon()}
<ChevronLeftIcon class="w-5 h-5" />
{/snippet}
{#snippet nextIcon()}
<ChevronRightIcon class="w-5 h-5" />
{/snippet}
</Pagination>
Badge - Status badge
<script>
import { Badge } from '@mrintel/villain-ui';
</script>
<!-- Basic variants -->
<Badge variant="success">Active</Badge>
<Badge variant="warning">Pending</Badge>
<Badge variant="error">Error</Badge>
<Badge variant="accent">Accent</Badge>
<!-- Feature variant - purple accent styling -->
<Badge variant="feature">New Feature</Badge>
<Badge variant="feature">Beta</Badge>
<!-- With hover effects -->
<Badge variant="feature" hover>Hoverable Badge</Badge>
<!-- With persistent glow (can be toggled dynamically for blinking) -->
<Badge variant="accent" glow>Glowing Badge</Badge>
<!-- With icon -->
<Badge variant="accent" size="md" hover>
{#snippet icon()}
<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
</svg>
{/snippet}
Verified
</Badge>
Props:
variant?: 'default' | 'success' | 'warning' | 'error' | 'accent' | 'feature' - Badge style (default: 'default')size?: 'sm' | 'md' - Badge size (default: 'md')icon?: Snippet - Optional icon contenthover?: boolean - Enable hover effects (darkened background + glow for accent/feature variants) (default: false)glow?: boolean - Apply accent glow effect, can be toggled dynamically for blinking animations (default: false)class?: string - Additional CSS classesNote: The feature variant creates a purple-accented badge perfect for highlighting new features or promotional content. Use hover={true} for interactive badges and glow={true} for persistent or animated glow effects.
Tag - Removable tag
<script>
import { Tag } from '@mrintel/villain-ui';
</script>
<Tag onRemove={() => console.log('Removed')}>JavaScript</Tag>
<Tag>TypeScript</Tag>
Icon Examples:
<!-- Tag with icon -->
<Tag variant="accent">
{#snippet icon()}
<StarIcon class="w-4 h-4" />
{/snippet}
Featured
</Tag>
<!-- Dismissible tag with icon -->
<Tag dismissible ondismiss={() => console.log('Removed')}>
{#snippet icon()}
<TagIcon class="w-4 h-4" />
{/snippet}
JavaScript
</Tag>
<!-- Multiple tags with different icons -->
<div class="flex gap-2">
<Tag>
{#snippet icon()}
<CheckCircleIcon class="w-4 h-4" />
{/snippet}
Verified
</Tag>
<Tag variant="accent">
{#snippet icon()}
<FireIcon class="w-4 h-4" />
{/snippet}
Trending
</Tag>
</div>
List - Styled list
<script>
import { List } from '@mrintel/villain-ui';
const items = ['Item 1', 'Item 2', 'Item 3'];
</script>
<List {items} variant="ordered" />
Icon Example:
<script>
import { List } from '@mrintel/villain-ui';
import { CheckIcon, XIcon, ClockIcon } from 'your-icon-library';
const items = [
{
label: 'Task completed',
icon: () => `{@render CheckIcon({ class: 'w-5 h-5 text-success' })}`
},
{
label: 'Task pending',
icon: () => `{@render ClockIcon({ class: 'w-5 h-5 text-warning' })}`
},
{
label: 'Task failed',
icon: () => `{@render XIcon({ class: 'w-5 h-5 text-error' })}`
}
];
</script>
<List {items} variant="unordered" />
<!-- Or with custom rendering -->
<List variant="unordered">
{#each items as item}
<li class="flex items-center gap-3">
{#if item.icon}
<span class="inline-flex items-center justify-center">
{@render item.icon()}
</span>
{/if}
{item.label}
</li>
{/each}
</List>
Avatar - User avatar
<script>
import { Avatar } from '@mrintel/villain-ui';
</script>
<Avatar src="/avatar.jpg" alt="User" size="md" />
<Avatar initials="JD" size="lg" />
CodeBlock - Presentational component for displaying syntax-highlighted code
A luxury-styled code display component that provides layout, styling, and optional features like line numbers, filename headers, and line highlighting. Consumers control syntax highlighting by providing pre-highlighted HTML via the default slot.
Key Features:
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
filename |
string |
undefined |
Optional filename to display in the header |
showLineNumbers |
boolean |
false |
Whether to show line numbers in the gutter |
lineCount |
number |
0 |
Total number of lines (required when showLineNumbers is true) |
highlightLines |
number[] |
[] |
Array of 1-indexed line numbers to highlight in the gutter |
showCopy |
boolean |
true |
Whether to show the copy button |
code |
string |
undefined |
Raw code text for copying (if not provided, extracts from rendered content) |
Important Notes:
.line class to each code line and .highlighted class to highlighted lines for consistent stylingshowLineNumbers, provide the lineCount prop for proper renderingBasic Usage:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
const code = `function hello() {
console.log('Hello, world!');
}`;
const highlightedCode = `<pre><code class="language-javascript">
<span class="token keyword">function</span> <span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'Hello, world!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>`;
</script>
<!-- Copy button shown by default, uses raw code text -->
<CodeBlock {code}>
{@html highlightedCode}
</CodeBlock>
<!-- Hide copy button if needed -->
<CodeBlock showCopy={false}>
{@html highlightedCode}
</CodeBlock>
With Line Numbers:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
const code = `function greet(name) {
return \`Hello, \${name}!\`;
}`;
const lineCount = code.split('\n').length;
// Assume you have a highlighter that returns HTML
const highlightedCode = yourHighlighter(code, 'javascript');
</script>
<CodeBlock showLineNumbers {lineCount}>
{@html highlightedCode}
</CodeBlock>
With Highlighted Lines:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
const code = `function calculate(a, b) {
const sum = a + b;
return sum * 2;
}`;
const lineCount = 4;
const highlightedCode = yourHighlighter(code, 'javascript');
const highlightLines = [2]; // Highlight line 2
</script>
<CodeBlock showLineNumbers {lineCount} {highlightLines}>
{@html highlightedCode}
</CodeBlock>
With Filename:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
const code = `export function add(a: number, b: number): number {
return a + b;
}`;
const highlightedCode = yourHighlighter(code, 'typescript');
</script>
<CodeBlock filename="utils.ts">
{@html highlightedCode}
</CodeBlock>
Integration with Shiki:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
import { codeToHtml } from 'shiki';
import { onMount } from 'svelte';
const code = `function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}`;
let highlightedCode = $state('');
let lineCount = $state(0);
onMount(async () => {
highlightedCode = await codeToHtml(code, {
lang: 'javascript',
theme: 'github-dark'
});
lineCount = code.split('\n').length;
});
</script>
<CodeBlock filename="fibonacci.js" showLineNumbers {lineCount} highlightLines={[2, 3]}>
{@html highlightedCode}
</CodeBlock>
Integration with Prism.js:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
import Prism from 'prismjs';
import 'prismjs/themes/prism-tomorrow.css';
const code = `const greeting = (name) => {
console.log(\`Hello, \${name}!\`);
};`;
const lineCount = code.split('\n').length;
const highlightedCode = Prism.highlight(code, Prism.languages.javascript, 'javascript');
</script>
<CodeBlock showLineNumbers {lineCount}>
<pre><code class="language-javascript">{@html highlightedCode}</code></pre>
</CodeBlock>
Integration with Highlight.js:
<script>
import { CodeBlock } from '@mrintel/villain-ui';
import hljs from 'highlight.js';
import 'highlight.js/styles/github-dark.css';
const code = `public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}`;
const lineCount = code.split('\n').length;
const highlightedCode = hljs.highlight(code, { language: 'java' }).value;
</script>
<CodeBlock filename="HelloWorld.java" showLineNumbers {lineCount}>
<pre><code class="language-java">{@html highlightedCode}</code></pre>
</CodeBlock>
Stat - Statistic display
<script>
import { Stat } from '@mrintel/villain-ui';
</script>
<Stat label="Total Users" value="1,234" change="+12.5%" trend="up" />
Sparkline - Lightweight micro trend visualizations
A zero-dependency SVG sparkline component for displaying micro trends in dashboards and data-rich interfaces. Perfect for showing quick visual trends without the overhead of a full charting library.
Key Features:
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
data |
number[] |
required | Array of numeric data points to plot |
color |
string |
var(--color-accent-soft) |
Line stroke color (CSS color or variable) |
height |
number |
40 |
Chart height in pixels |
width |
number |
200 |
Chart width in pixels |
showDots |
boolean |
false |
Show dots at each data point |
showFill |
boolean |
false |
Show gradient fill below the line |
strokeWidth |
number |
2 |
Line thickness in pixels |
animationDuration |
number |
500 |
Animation duration in ms (0 to disable) |
Basic Usage:
<script>
import { Sparkline } from '@mrintel/villain-ui';
const weeklyData = [120, 135, 128, 142, 155, 148, 160];
</script>
<Sparkline data={weeklyData} />
With Fill and Dots:
<script>
import { Sparkline } from '@mrintel/villain-ui';
const trendData = [10, 15, 12, 18, 22, 19, 25];
</script>
<Sparkline
data={trendData}
showFill={true}
showDots={true}
height={60}
color="var(--color-success)"
/>
Integrated with Stat Component (Gym Planner Example):
<script>
import { Stat, Sparkline } from '@mrintel/villain-ui';
const volumeTrend = [12500, 13200, 12800, 14100, 15200, 14800, 16000];
</script>
<Stat
label="7-Day Volume"
value="16,000 lbs"
trend="up"
change={12.5}
description="gym planner example"
>
<div style="margin-top: 1rem;">
<Sparkline
data={volumeTrend}
height={40}
width={180}
color="var(--color-success)"
showFill={true}
/>
</div>
</Stat>
Custom Colors and Sizes:
<script>
import { Sparkline } from '@mrintel/villain-ui';
const revenueData = [5400, 5800, 5200, 6100, 6500, 6200, 6800];
const downtrendData = [180, 175, 165, 158, 150, 145, 138];
</script>
<!-- Success trend (green) -->
<Sparkline data={revenueData} color="var(--color-success)" showFill={true} />
<!-- Error trend (red) -->
<Sparkline data={downtrendData} color="var(--color-error)" />
<!-- Large with thick stroke -->
<Sparkline
data={revenueData}
height={80}
width={400}
strokeWidth={3}
color="var(--color-success)"
showFill={true}
/>
Accessibility:
prefers-reduced-motion - disables animation when requestedrole="img" and aria-label for screen readersFor Advanced Charting:
Sparkline is designed for simple micro trends. For complex visualization needs (multi-series charts, axes, legends, tooltips, bar/pie/scatter charts), integrate established charting libraries:
These libraries integrate easily with villain-ui theming via CSS variables.
CalendarGrid - Interactive monthly calendar with event support
A fully-featured calendar grid component for displaying events, selecting dates, and navigating months. Perfect for scheduling interfaces, date selection, and event dashboards.
Key Features:
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
month |
Date |
new Date() |
Currently displayed month (bindable) |
events |
CalendarEvent[] |
[] |
Array of events to display |
selectedDate |
Date |
undefined |
Currently selected date (bindable) |
onDateSelect |
(date: Date) => void |
- | Callback when date is clicked |
onMonthChange |
(date: Date) => void |
- | Callback when month changes |
renderCell |
Snippet<[CellData]> |
- | Custom cell rendering snippet |
weekStartsOn |
0 | 1 |
0 |
Week start day (0=Sunday, 1=Monday) |
showWeekNumbers |
boolean |
false |
Display week numbers |
highlightToday |
boolean |
true |
Highlight current date |
class |
string |
'' |
Additional CSS classes |
CalendarEvent Interface:
interface CalendarEvent {
id: string;
title: string;
date: Date | string;
color?: string;
description?: string;
}
CellData Interface (for renderCell):
interface CellData {
date: Date;
events: CalendarEvent[];
isToday: boolean;
isSelected: boolean;
isCurrentMonth: boolean;
isEmpty: boolean;
}
Basic Usage:
<script>
import { CalendarGrid } from '@mrintel/villain-ui';
let currentMonth = $state(new Date());
let selectedDate = $state();
const events = [
{ id: '1', title: 'Team Meeting', date: '2024-01-15', color: 'var(--color-accent)' },
{ id: '2', title: 'Project Deadline', date: '2024-01-20', color: 'var(--color-error)' }
];
</script>
<CalendarGrid
bind:month={currentMonth}
bind:selectedDate
{events}
onDateSelect={(date) => console.log('Selected:', date)}
onMonthChange={(date) => console.log('Month changed:', date)}
/>
With Custom Cell Rendering:
<script>
import { CalendarGrid } from '@mrintel/villain-ui';
let currentMonth = $state(new Date());
const events = [...]; // Your events array
</script>
<CalendarGrid bind:month={currentMonth} {events}>
{#snippet renderCell(cellData)}
<div class="custom-cell" class:has-events={cellData.events.length > 0}>
<div class="date-number">{cellData.date.getDate()}</div>
{#if cellData.events.length > 0}
<div class="event-indicators">
{#each cellData.events.slice(0, 3) as event}
<div class="event-dot" style="background: {event.color}"></div>
{/each}
</div>
{/if}
</div>
{/snippet}
</CalendarGrid>
With Week Starting on Monday:
<CalendarGrid bind:month={currentMonth} {events} weekStartsOn={1} showWeekNumbers={true} />
Keyboard Navigation:
Arrow Keys - Navigate between datesEnter or Space - Select focused dateHome - Go to first day of weekEnd - Go to last day of weekPage Up - Go to previous monthPage Down - Go to next monthAccessibility Features:
Hero - Full-width hero section for page introductions
<script>
import { Hero } from '@mrintel/villain-ui';
</script>
<Hero>
{#snippet title()}
<h1 class="text-5xl font-bold">Welcome to Villain UI</h1>
{/snippet}
{#snippet text()}
<p class="text-xl text-neutral-400">A luxury Svelte 5 component library with modern villain aesthetics</p>
{/snippet}
{#snippet features()}
<div class="flex gap-4 justify-center">
<span class="px-4 py-2 bg-accent-500/10 rounded-lg">Svelte 5</span>
<span class="px-4 py-2 bg-accent-500/10 rounded-lg">TypeScript</span>
<span class="px-4 py-2 bg-accent-500/10 rounded-lg">Accessible</span>
</div>
{/snippet}
</Hero>
Props:
title?: Snippet - Hero title contenttext?: Snippet - Hero description/subtitle textfeatures?: Snippet - Optional feature tags or highlightschildren?: Snippet - Additional custom contentclass?: string - Additional CSS classesPortal - Render content in different DOM location
<script>
import { Portal } from '@mrintel/villain-ui';
</script>
<Portal target="body">
<div>This renders at the end of body</div>
</Portal>
Collapse - Collapsible content
<script>
import { Collapse } from '@mrintel/villain-ui';
let open = $state(false);
</script>
<Collapse title="Click to expand" open={open} onToggle={() => open = !open}>
<p>Hidden content that can be toggled</p>
</Collapse>
Accordion - Accordion with multiple items
<script>
import { Accordion } from '@mrintel/villain-ui';
const items = [
{ id: '1', title: 'Section 1', content: 'Content for section 1' },
{ id: '2', title: 'Section 2', content: 'Content for section 2' }
];
let openItems = $state([]);
</script>
<Accordion {items} bind:openItems mode="multiple" />
Carousel - Image/content carousel
<script>
import { Carousel } from '@mrintel/villain-ui';
const items = [
{ id: '1', content: 'Slide 1' },
{ id: '2', content: 'Slide 2' },
{ id: '3', content: 'Slide 3' }
];
let currentIndex = $state(0);
</script>
<Carousel {items} bind:currentIndex autoplay showDots showArrows />
ScrollArea - Custom scrollable area
<script>
import { ScrollArea } from '@mrintel/villain-ui';
</script>
<ScrollArea height="300px">
<div>Long scrollable content...</div>
</ScrollArea>
SystemConsole - Terminal-style console with message history
A retro terminal console component with typewriter effects, scanlines, and glow effects. Perfect for command-line interfaces, log viewers, and terminal-style interactions.
Key Features:
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
messages |
ConsoleMessage[] |
[] |
Array of console messages |
prompt |
string |
'>' |
Prompt character/text (e.g., '>', '$', 'λ') |
placeholder |
string |
'Enter command...' |
Input placeholder text |
height |
string |
'500px' |
Console height |
maxHeight |
string |
'80vh' |
Maximum console height |
showTimestamps |
boolean |
false |
Display message timestamps |
autoScroll |
boolean |
true |
Auto-scroll to new messages |
typewriterEffect |
boolean |
false |
Animate system messages |
typewriterSpeed |
number |
50 |
Characters per second for animation |
showScanlines |
boolean |
true |
Show retro scanline effect |
glowEffect |
boolean |
true |
Show text glow effect |
onSubmit |
(input: string) => void |
- | Called when command is submitted |
disabled |
boolean |
false |
Disable input |
class |
string |
'' |
Additional CSS classes |
ConsoleMessage Interface:
interface ConsoleMessage {
id: string;
role: 'user' | 'system';
content: string;
timestamp?: Date;
variant?: 'default' | 'success' | 'warning' | 'error' | 'info';
}
Basic Usage:
<script>
import { SystemConsole } from '@mrintel/villain-ui';
let messages = $state([
{ id: '1', role: 'system', content: 'System initialized...', timestamp: new Date() },
{ id: '2', role: 'user', content: 'help', timestamp: new Date() },
{ id: '3', role: 'system', content: 'Available commands: help, status, exit', variant: 'info' }
]);
function handleCommand(input) {
// Add user message
messages = [...messages, {
id: Date.now().toString(),
role: 'user',
content: input,
timestamp: new Date()
}];
// Process command and add system response
setTimeout(() => {
messages = [...messages, {
id: (Date.now() + 1).toString(),
role: 'system',
content: `Executed: ${input}`,
timestamp: new Date(),
variant: 'success'
}];
}, 500);
}
</script>
<SystemConsole
{messages}
prompt="$"
showTimestamps={true}
onSubmit={handleCommand}
/>
With Typewriter Effect:
<SystemConsole
{messages}
typewriterEffect={true}
typewriterSpeed={80}
showScanlines={true}
glowEffect={true}
height="600px"
onSubmit={handleCommand}
/>
SystemInterface - Advanced system interface with panels
A sophisticated system interface component with multi-panel layout, staged message revelation, and processing states. Ideal for AI assistants, command centers, and advanced terminal interfaces.
Key Features:
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
messages |
SystemMessage[] |
[] |
Array of system messages |
onSubmit |
(input: string) => void |
- | Called when directive is submitted |
processing |
boolean |
false |
Show processing animation |
placeholder |
string |
'ENTER DIRECTIVE' |
Input placeholder text |
height |
string |
'600px' |
Interface height |
autoScroll |
boolean |
true |
Auto-scroll to new messages |
stagingDelay |
number |
150 |
Delay (ms) between message reveals |
leftPanel |
Snippet |
- | Left sidebar content |
rightPanel |
Snippet |
- | Right sidebar content |
topPanel |
Snippet |
- | Top panel content |
bottomPanel |
Snippet |
- | Bottom panel content |
class |
string |
'' |
Additional CSS classes |
SystemMessage Interface:
interface SystemMessage {
id: string;
content: string | MessageContentType;
timestamp?: number;
tier?: 'informational' | 'analysis' | 'directive' | 'warning' | 'critical';
}
type MessageContentType =
| { type: 'text'; value: string }
| { type: 'code'; value: string; language?: string }
| { type: 'data'; value: Record<string, any> }
| { type: 'status'; label: string; value: string; status: 'ok' | 'warning' | 'error' | 'info' };
Basic Usage:
<script>
import { SystemInterface } from '@mrintel/villain-ui';
let messages = $state([
{
id: '1',
content: 'SYSTEM ONLINE',
timestamp: Date.now(),
tier: 'directive'
},
{
id: '2',
content: 'Analyzing input parameters...',
timestamp: Date.now() + 100,
tier: 'analysis'
}
]);
let processing = $state(false);
function handleDirective(input) {
processing = true;
messages = [...messages, {
id: Date.now().toString(),
content: { type: 'text', value: input },
timestamp: Date.now(),
tier: 'directive'
}];
// Simulate processing
setTimeout(() => {
messages = [...messages, {
id: (Date.now() + 1).toString(),
content: `Directive executed: ${input}`,
timestamp: Date.now(),
tier: 'informational'
}];
processing = false;
}, 1500);
}
</script>
<SystemInterface
{messages}
{processing}
onSubmit={handleDirective}
/>
With Side Panels:
<SystemInterface {messages} onSubmit={handleDirective}>
{#snippet leftPanel()}
<div class="panel-content">
<h3>System Status</h3>
<div>CPU: 45%</div>
<div>Memory: 2.1GB</div>
</div>
{/snippet}
{#snippet rightPanel()}
<div class="panel-content">
<h3>Active Processes</h3>
<div>Process 1: Running</div>
<div>Process 2: Idle</div>
</div>
{/snippet}
</SystemInterface>
With Rich Content Types:
<script>
const messages = [
{
id: '1',
content: { type: 'text', value: 'Starting analysis...' },
tier: 'informational'
},
{
id: '2',
content: {
type: 'code',
value: 'const result = await analyze(data);',
language: 'javascript'
},
tier: 'analysis'
},
{
id: '3',
content: {
type: 'status',
label: 'Analysis',
value: 'Complete',
status: 'ok'
},
tier: 'directive'
},
{
id: '4',
content: {
type: 'data',
value: { accuracy: 0.95, confidence: 0.88 }
},
tier: 'informational'
}
];
</script>
<SystemInterface {messages} onSubmit={handleDirective} />
The library includes comprehensive global styles that provide the foundation for the luxury dark aesthetic. When you import theme.css, you get:
Base HTML/Body Styling:
--color-base-0: #0a0a0a - Onyx Black)Typography System:
Built-in Animations: The theme includes several keyframe animations ready to use:
fade-in - Simple opacity fadefade-out - Opacity fade outfade-up - Fade in with upward movementglow-pulse - Pulsing accent glow effectslide-in-left/right/top/bottom - Directional slide animationsCustom Utility Classes:
.text-glow - Apply accent text glow effect.text-gradient - Gradient text with purple-to-soft-purple gradient and transparent fill.glass-panel - Glass morphism with backdrop blur and borders.accent-glow - Accent color box-shadow glow.hover-lift - Lift element on hover with glow and shadow.hover-lift-enhanced - Enhanced lift on hover with accent border and glow (stronger effect).card-icon - Centered icon container with accent color and 4xl sizing.hero-section - Centered hero section layout with padding (4rem top, 3rem bottom, 3rem margin-bottom). Used by the Hero component as its base layout..feature-tags - Horizontal flexbox container for feature tags with center alignment and wrapping. Used by the Hero component for its features slot..feature-tag - Pill-shaped feature badge with accent background, border glow, and hover effect.metal-edge - Specular metallic border highlights.obsidian-surface - Flat black surface with subtle gradient reflection.sidebar-collapsed-icon - Centered icon display for collapsed sidebar states.sidebar-collapsed-letter - Accent-colored circle with first letter for collapsed sidebar items without icons@mrintel/villain-ui uses a comprehensive CSS variable system that allows complete customization without touching component code. All theme variables are defined in theme.css and can be overridden in your own CSS.
Create a custom CSS file (e.g., custom-theme.css) and import it after the library theme:
/* custom-theme.css */
/* Override accent color from purple to blue */
:root {
--color-accent: #3B82F6;
--color-accent-soft: #60A5FA;
--color-accent-dark: #1E40AF;
--shadow-accent-glow:
0 0 20px rgba(59, 130, 246, 0.4),
0 0 40px rgba(59, 130, 246, 0.2),
0 0 60px rgba(59, 130, 246, 0.1);
--shadow-text-glow:
0 0 20px rgba(59, 130, 246, 0.5),
0 0 40px rgba(59, 130, 246, 0.3);
}
Import order in your app:
import '@mrintel/villain-ui/theme.css';
import './custom-theme.css'; // Your overrides
:root {
--font-heading: 'Montserrat', sans-serif;
--font-body: 'Open Sans', sans-serif;
--font-mono: 'Fira Code', monospace;
--text-h1-size: 4rem;
--text-body-size: 1.125rem;
}
The library uses calculated, precision border radii for the "villain" aesthetic:
:root {
--radius-sm: 3px; /* Subtle taper */
--radius-md: 6px; /* Controlled precision */
--radius-lg: 8px; /* Engineered corners */
--radius-xl: 10px; /* Maximum rounding - still calculated */
--radius-2xl: 14px; /* Reserved for large surfaces */
--radius-pill: 999px; /* Intentional full-round (use sparingly) */
}
Base Colors (Modern Villain Luxury)
--color-base-0: #0a0a0a - Onyx Black (deepest background)--color-base-1: #121212 - Elevated surface--color-base-2: #1a1a1a - Panel layer--color-base-3: #242424 - Highest elevation--color-surface: Alias for base-1--color-panel: Alias for base-2--color-overlay: rgba(0, 0, 0, 0.75) - Modal backdropAccent Colors (Royal Purple & Crimson)
--color-accent: #6b21a8 - Royal Purple (primary)--color-accent-soft: #8b5cf6 - Lighter purple variant--color-accent-dark: #581c87 - Darker purple variant--color-secondary: #3b82f6 - Electric Blue--color-crimson: #ef4444 - Crimson Red accentText Colors
--color-text: #e0e0e0 - Primary text (refined gray)--color-text-soft: #a3a3a3 - Secondary text--color-text-muted: #737373 - Muted/disabled textState Colors (Bold & Commanding)
--color-success: #10b981 - Emerald green--color-warning: #f59e0b - Amber--color-error: #ef4444 - Crimson RedBorder Colors (Neon Edges)
--color-border: rgba(255, 255, 255, 0.10) - Default border--color-border-strong: rgba(255, 255, 255, 0.20) - Emphasized border--color-border-glow: rgba(107, 33, 168, 0.30) - Purple glow edgeOverlay Colors (Alpha Transparency)
--color-accent-overlay-5: rgba(107, 33, 168, 0.05) - Very subtle accent tint--color-accent-overlay-10: rgba(107, 33, 168, 0.1) - Subtle accent background--color-accent-overlay-15: rgba(107, 33, 168, 0.15) - Light accent overlay--color-accent-overlay-20: rgba(107, 33, 168, 0.2) - Medium accent overlay--color-accent-overlay-30: rgba(107, 33, 168, 0.3) - Strong accent overlay--color-accent-overlay-50: rgba(107, 33, 168, 0.5) - Semi-transparent accent--color-accent-overlay-70: rgba(107, 33, 168, 0.7) - Dense accent overlay--color-secondary-overlay-10: rgba(127, 61, 255, 0.1) - Subtle secondary tint--color-secondary-overlay-20: rgba(127, 61, 255, 0.2) - Medium secondary overlay--color-neutral-overlay-2: rgba(255, 255, 255, 0.02) - Subtle white tint--color-shadow-overlay-20: rgba(0, 0, 0, 0.2) - Shadow layer--color-success-overlay-15: rgba(0, 232, 151, 0.15) - Success state background--color-warning-overlay-15: rgba(255, 200, 97, 0.15) - Warning state background--color-error-overlay-15: rgba(255, 74, 106, 0.15) - Error state backgroundFont Families (Modern Villain Luxury)
--font-heading: 'Inter', sans-serif - Unified typography for headings--font-body: 'Inter', sans-serif - Body text--font-mono: 'JetBrains Mono', monospace - Code and numeric displayHeading Text Scales (h1-h6)
--text-h1-size: 3.5rem (56px)
--text-h1-line-height: 1.2
--text-h1-weight: 700
--text-h1-letter-spacing: -0.02em
--text-h2-size: 2.5rem (40px)
--text-h2-line-height: 1.25
--text-h2-weight: 600
--text-h2-letter-spacing: -0.015em
--text-h3-size: 2rem (32px)
--text-h3-line-height: 1.3
--text-h3-weight: 600
--text-h3-letter-spacing: -0.01em
--text-h4-size: 1.5rem (24px)
--text-h4-line-height: 1.35
--text-h4-weight: 600
--text-h4-letter-spacing: -0.01em
--text-h5-size: 1.25rem (20px)
--text-h5-line-height: 1.4
--text-h5-weight: 500
--text-h5-letter-spacing: -0.005em
--text-h6-size: 1rem (16px)
--text-h6-line-height: 1.5
--text-h6-weight: 500
--text-h6-letter-spacing: 0
Body Text Scales
--text-body-size: 1rem
--text-body-line-height: 1.6
--text-body-weight: 400
--text-body-letter-spacing: 0.01em
--text-caption-size: 0.875rem
--text-caption-line-height: 1.5
--text-caption-weight: 400
--text-caption-letter-spacing: 0.015em
Tailwind-Compatible Text Sizes
--text-xs through --text-9xl with corresponding line heights--text-2xl: 1.5rem, --text-2xl--line-height: 2remBorder Radii (Rounded 2XL Corners)
--radius-none: 0px--radius-sm: 6px - Small rounded--radius-md: 10px - Medium rounded--radius-lg: 14px - Large rounded--radius-xl: 18px - Extra large--radius-2xl: 24px - 2XL signature rounded corners--radius-pill: 999px - Full roundSpacing
--spacing: 0.25rem - Base spacing unit--spacing-4.5: 1.125rem--spacing-18: 4.5remZ-Index Scale
--z-0: 0 - Base layer (default)--z-10: 10 - Slightly elevated--z-20: 20 - Elevated content--z-30: 30 - Dropdowns and popovers--z-40: 40 - Sidebar navigation--z-50: 50 - Top navigation, modals, highest overlaysUsage Example:
.custom-overlay {
z-index: var(--z-50);
background: var(--color-accent-overlay-20);
border-radius: var(--radius-lg);
backdrop-filter: blur(12px);
}
Shadows (Glow & Depth)
--shadow-accent-glow: Layered Royal Purple glow effect (20px/40px/60px)--shadow-crimson-glow: Crimson Red glow effect (20px/40px)--shadow-deep: 0 10px 40px rgba(0, 0, 0, 0.6)--shadow-text-glow: Text-specific Royal Purple glow (20px/40px)Glass Effect (Modern Blur)
--glass-panel-background: rgba(255, 255, 255, 0.05) - Subtle glass panel--glass-panel-blur: 12px - Modern blur effectEasing Curves
--ease-luxe: cubic-bezier(0.23, 1, 0.32, 1) - Smooth luxury motion--ease-sharp: cubic-bezier(0.4, 0.1, 0.2, 1) - Snappy transitionsDuration Scale
--duration-75 through --duration-1000 (75ms, 100ms, 150ms, 200ms, 300ms, 500ms, 700ms, 1000ms)Opacity Scale
--opacity-0 through --opacity-100 in increments of 5-10The library provides custom utility classes you can use directly in your markup:
Visual Effects:
.text-glow - Apply accent glow to text with shadow effect.accent-glow - Accent color glow box-shadow effect.glass-panel - Glass morphism with backdrop blur (14px), semi-transparent background, border, and deep shadow.hover-lift - Lift element 2px on hover with combined glow and shadowSurface Treatments:
.metal-edge - Specular metallic highlights on top and left borders.obsidian-surface - Flat black surface with subtle diagonal gradient reflectionExample usage:
<div class="glass-panel accent-glow hover-lift">
<h2 class="text-glow">Glowing Title</h2>
<div class="obsidian-surface metal-edge">
<p>Premium surface treatment</p>
</div>
</div>
The theme includes pre-defined keyframe animations ready to use with Tailwind's animate-* utilities or custom CSS:
Opacity Animations:
fade-in - Fade from 0 to full opacityfade-out - Fade from full to 0 opacityCombined Animations:
fade-up - Fade in while moving up 20pxGlow Effects:
glow-pulse - Pulsing accent glow (40%-60% intensity cycle)Directional Slides:
slide-in-left - Slide in from left with fadeslide-in-right - Slide in from right with fadeslide-in-top - Slide in from top with fadeslide-in-bottom - Slide in from bottom with fadeExample usage:
.my-element {
animation: fade-up 0.3s var(--ease-luxe);
}
.my-modal {
animation: fade-in 0.2s var(--ease-sharp);
}
.my-button:hover {
animation: glow-pulse 2s infinite;
}
The brand structure (depth system, spacing, motion curves) persists even when colors change, maintaining the luxury aesthetic regardless of your chosen palette.
When using both Navbar and Sidebar together, they automatically coordinate their positioning. The Sidebar detects the Navbar's presence and adjusts its top position to start just below it. Here's the recommended structure:
<script>
import { page } from '$app/stores';
import { Navbar, Sidebar } from '@mrintel/villain-ui';
let sidebarOpen = $state(true);
$: currentPath = $page.url.pathname;
</script>
<!-- Navbar sits on top with z-50 and gets data-navbar attribute automatically -->
<Navbar position="sticky" height="md" currentPath={currentPath}>
{#snippet logo()}
<YourLogo />
{/snippet}
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</Navbar>
<!-- Sidebar automatically detects Navbar and positions below it (z-40) -->
<Sidebar bind:open={sidebarOpen} side="left" width="md" currentPath={currentPath}>
<nav>
<a href="/dashboard">
<DashboardIcon class="w-5 h-5" />
<span>Dashboard</span>
</a>
<a href="/analytics">
<ChartIcon class="w-5 h-5" />
<span>Analytics</span>
</a>
<a href="/settings">
<SettingsIcon class="w-5 h-5" />
<span>Settings</span>
</a>
</nav>
</Sidebar>
<!-- Main content with appropriate margin/padding -->
<main class="ml-64 p-6">
<!-- Adjust ml-64 based on sidebar width (sm: 56, md: 64, lg: 80) -->
<!-- No margin-top needed - Sidebar handles its own positioning! -->
<slot />
</main>
Tips:
data-navbar attribute and adjusts its top position automatically. No manual margin-top needed on Sidebar.margin-left to your main content based on sidebar width:width="sm" (224px/56 Tailwind units): Use ml-56width="md" (256px/64 Tailwind units): Use ml-64 (default)width="lg" (320px/80 Tailwind units): Use ml-80ml-14, ml-16, or ml-20 respectivelymd:ml-64 to adjust layout on mobilelet sidebarOpen = $state(window.innerWidth >= 768)currentPath prop on both components for automatic active state management (see Active State Management section)Navbar Only (No Sidebar):
<Navbar position="sticky" currentPath={currentPath}>
<!-- Navigation links -->
</Navbar>
<main class="p-6">
<!-- No margin-left needed -->
<slot />
</main>
Sidebar Only (No Navbar):
<Sidebar open={true} currentPath={currentPath}>
<!-- Navigation links -->
</Sidebar>
<main class="ml-64 p-6">
<!-- Sidebar starts from top automatically -->
<slot />
</main>
Both with Collapsible Sidebar:
<script>
let sidebarOpen = $state(true);
$: mainMargin = sidebarOpen ? 'ml-64' : 'ml-16'; // Adjust for collapsed width
</script>
<Navbar position="sticky" currentPath={currentPath}>
<button onclick={() => sidebarOpen = !sidebarOpen}>
<MenuIcon />
</button>
<!-- Other nav items -->
</Navbar>
<Sidebar bind:open={sidebarOpen} currentPath={currentPath}>
<!-- Navigation links -->
</Sidebar>
<main class="{mainMargin} p-6 transition-all duration-300">
<slot />
</main>
Navbar and Sidebar components now support automatic active state management via the optional currentPath prop. When provided, the components automatically add the active class to child <a> and <button> elements whose href attribute matches the current path. This eliminates the need for manual class management while preserving support for manual .active class usage.
currentPath is provided, components use a $effect to query child links and buttonshref matching currentPath automatically receive the active classactive classeshref attributes and data-href attributes (for buttons)currentPath changes<script>
import { page } from '$app/stores';
import { Navbar, Sidebar } from '@mrintel/villain-ui';
// Automatically reactive - updates when route changes
$: currentPath = $page.url.pathname;
</script>
<!-- Navbar with automatic active state -->
<Navbar currentPath={currentPath}>
<a href="/">Home</a>
<a href="/about">About</a>
<a href="/contact">Contact</a>
</Navbar>
<!-- Sidebar with automatic active state -->
<Sidebar currentPath={currentPath}>
<a href="/dashboard">Dashboard</a>
<a href="/settings">Settings</a>
<a href="/profile">Profile</a>
</Sidebar>
<!-- No need to manually add class={currentPath === '/dashboard' ? 'active' : ''} -->
<script>
import { page } from '$app/stores';
import { Sidebar } from '@mrintel/villain-ui';
// For nested routes, you might want to match path prefixes
$: currentPath = $page.url.pathname;
// Helper to check if a path is active (including sub-routes)
function isActive(path: string) {
return currentPath === path || currentPath.startsWith(path + '/');
}
</script>
<Sidebar currentPath={currentPath}>
<a href="/dashboard">Dashboard</a>
<!-- For nested routes, use manual class for prefix matching -->
<a href="/settings" class={isActive('/settings') ? 'active' : ''}>
Settings
</a>
</Sidebar>
<script>
import { Navbar } from '@mrintel/villain-ui';
let currentPath = $state('/home');
function navigate(path: string) {
currentPath = path;
// Your custom navigation logic
}
</script>
<Navbar currentPath={currentPath}>
<a href="/home" onclick={(e) => { e.preventDefault(); navigate('/home'); }}>Home</a>
<a href="/about" onclick={(e) => { e.preventDefault(); navigate('/about'); }}>About</a>
<a href="/contact" onclick={(e) => { e.preventDefault(); navigate('/contact'); }}>Contact</a>
</Navbar>
<script>
import { page } from '$app/stores';
import { Sidebar } from '@mrintel/villain-ui';
$: currentPath = $page.url.pathname;
</script>
<Sidebar currentPath={currentPath}>
<!-- These use automatic active state via currentPath -->
<a href="/dashboard">Dashboard</a>
<a href="/analytics">Analytics</a>
<!-- This uses manual active class (takes precedence) -->
<a href="/special" class="active">Special Page (Always Active)</a>
<!-- Buttons work too with data-href -->
<button data-href="/action" onclick={handleAction}>Action</button>
</Sidebar>
currentPath prop for simple exact-match scenarios (most common)currentPath with manual classes.active classes always take precedence over automatic managementcurrentPath prop is optional - components work perfectly without itdata-href attribute to enable automatic active state$page.url.pathname in SvelteKit for automatic reactivity@mrintel/villain-ui is built with TypeScript in strict mode and includes complete type definitions.
dist/index.d.tsImport types directly from components:
import type { Button } from '@mrintel/villain-ui';
// Component props are fully typed
const props: ComponentProps<typeof Button> = {
variant: 'primary',
size: 'md',
disabled: false
};
For type-safe usage, import component prop types directly:
import type {
ButtonProps,
InputProps,
ModalProps,
TabsProps
} from '@mrintel/villain-ui';
// Use in your components
const buttonConfig: ButtonProps = {
variant: 'primary',
size: 'md',
disabled: false
};
const modalConfig: ModalProps = {
open: true,
title: 'Confirmation',
closeOnEscape: true
};
The following component prop types are exported for TypeScript users:
Button Types:
ButtonProps - Standard button componentIconButtonProps - Icon-only buttonFloatingActionButtonProps - Floating action button (FAB)LinkButtonProps - Link styled as buttonForm Types:
InputProps - Text input componentTextareaProps - Multi-line text inputSelectProps - Dropdown selectCheckboxProps - Checkbox inputSwitchProps - Toggle switchRadioGroupProps - Radio button groupDatePickerProps - Date picker componentTimePickerProps - Time picker componentDateTimePickerProps - Combined date and time pickerLayout Types:
CardProps - Content cardNavigation Types:
TabsProps - Tabbed interfaceOverlay Types:
ModalProps - Modal dialogDrawerProps - Slide-out drawerAlertProps - Alert messageTooltipProps - Hover tooltipUtility Types:
AccordionProps - Accordion containerData Types:
SparklineProps - Sparkline chart componentNote: Additional component prop types may be added in future releases. Components without exported prop types can still be used with TypeScript through Svelte's built-in type inference.
All components support lowercase event handlers with proper typing:
import { Button } from '@mrintel/villain-ui';
<Button onclick={(event: MouseEvent) => {
console.log('Button clicked', event);
}}>
Click Me
</Button>
@mrintel/villain-ui targets modern browsers that support:
backdrop-filter for glass morphismSupported Browsers:
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit issues and pull requests.
npm run validate to ensure all checks passsrc/index.tsdemo-ui/All pull requests are automatically validated via GitHub Actions CI, which runs:
The CI must pass before a PR can be merged.
Built with ❤️ for the modern web