Svelte components for the Classic theme system
npm install @classic-homes/theme-svelteSvelte 5 components for the Classic Theme design system. Built on Bits UI primitives and styled with Tailwind CSS.
``bash`
npm install @classic-homes/theme-svelte @classic-homes/theme-tokens
Add the Classic Theme preset to your tailwind.config.js:
`js
import preset from '@classic-homes/theme-tailwind-preset';
export default {
presets: [preset],
content: [
'./src/*/.{html,js,svelte,ts}',
'./node_modules/@classic-homes/theme-svelte/*/.{html,js,svelte,ts}',
],
};
`
Import the CSS tokens in your app's root CSS file:
`css`
@import '@classic-homes/theme-tokens/css';
Or in your root layout:
`svelte`
`svelte
`
- Button - Buttons with variants (default, secondary, destructive, outline, ghost, link)Input
- - Text input fieldTextarea
- - Multi-line text inputLabel
- - Form labelsCheckbox
- - Checkbox inputSwitch
- - Toggle switchSelect
- - Dropdown selectFormField
- - Combined label + input + error handling
- AppShell - Application wrapper with skip links and toast containerDashboardLayout
- - Sidebar + header layout for dashboardsPublicLayout
- - Header + footer layout for public pagesFormPageLayout
- - Centered form page layoutSidebar
- - Navigation sidebarHeader
- - Page headerFooter
- - Page footer
- Alert - Alert messages (default, destructive, success, warning, info)AlertDialog
- - Confirmation dialogsDialog
- - Modal dialogsToast
- - Toast notificationsToastContainer
- - Toast notification containerSpinner
- - Loading spinnerSkeleton
- - Loading skeleton
- Card - Card container with header, content, footerBadge
- - Status badgesDataTable
- - Sortable data tableTabs
- - Tab navigationTooltip
- - Hover tooltipsDropdownMenu
- - Dropdown menusAvatar
- - User avatars
- LogoMain - Main logo componentLoadingLogo
- - Animated loading logo
Notification UI components are available via a separate entry point. This makes the @classic-homes/notifications dependency optional - you only need it if you use these components.
`bash`Install the notifications package if using notification components
npm install @classic-homes/notifications
`svelte`
Available notification components:
- NotificationBadge - Unread count badgeNotificationItem
- - Single notification cardNotificationList
- - List of notifications with empty stateNotificationDialog
- - Detail dialog for a notificationNotificationFilters
- - Filter tabs (all/read/unread)NotificationBulkActions
- - Bulk action toolbar
Components in this library do not include built-in error boundaries to give you full control over error handling. We recommend implementing error handling at your application's root level.
Create an ErrorBoundary component to catch and handle errors gracefully:
`svelte
{#if error}
{#if fallback}
{@render fallback(error, reset)}
{:else}
{error.message}
$3
Wrap your
AppShell with the ErrorBoundary:`svelte
`$3
You can provide a custom fallback UI:
`svelte
{#snippet fallback(error, reset)}
Oops!
{error.message}
{/snippet}
`Toast Notifications
The library includes a toast store for managing notifications:
`svelte
`Toast methods:
-
toastStore.success(message, options?) - Green success toast
- toastStore.error(message, options?) - Red error toast (persistent by default)
- toastStore.warning(message, options?) - Yellow warning toast
- toastStore.info(message, options?) - Blue info toast
- toastStore.add(toast) - Add custom toast
- toastStore.remove(id) - Remove toast by ID
- toastStore.clear() - Remove all toastsSidebar State
For layouts with collapsible sidebars, use the sidebar store:
`svelte
`TypeScript Support
All components are fully typed. Import types as needed:
`typescript
import type {
NavItem,
NavSection,
User,
Tab,
FileMetadata,
DataTableColumn,
SelectOption,
} from '@classic-homes/theme-svelte';
`Svelte 5 Runes
All components use Svelte 5 runes syntax:
-
$props() for component props
- $state() for reactive state
- $derived() for computed values
- $effect() for side effects
- $bindable()` for two-way bindingComponents are built with accessibility in mind:
- Proper ARIA attributes
- Keyboard navigation support
- Focus management
- Screen reader friendly
- Skip links in AppShell
MIT