@phcdevworks/spectre-ui is the implementation layer between
@phcdevworks/spectre-tokens
and downstream adapters or apps.
Maintained by PHCDevworks, it turns Spectre tokens into reusable CSS bundles, Tailwind tooling, and type-safe class recipes. It is framework-agnostic, token-driven, and follows a strict zero-hex policy so visual values do not drift locally.
Contributing | Changelog | Security Policy
- Ships precompiled CSS:
index.css,base.css,components.css, andutilities.css - Provides Tailwind theme and preset helpers built from Spectre tokens
- Exports type-safe class recipes for shared UI patterns
- Keeps CSS classes and recipe APIs aligned
- Gives adapters and apps a stable styling contract instead of re-implementing classes
- Enforces a zero-hex approach so visual values stay tied to
@phcdevworks/spectre-tokens
npm install @phcdevworks/spectre-uiImport the full stylesheet:
import '@phcdevworks/spectre-ui/index.css'Or import the bundles separately:
import '@phcdevworks/spectre-ui/base.css'
import '@phcdevworks/spectre-ui/components.css'
import '@phcdevworks/spectre-ui/utilities.css'Use Spectre tokens as the source of truth for your Tailwind theme:
// tailwind.config.ts
import type { Config } from 'tailwindcss'
import { createSpectreTailwindPreset } from '@phcdevworks/spectre-ui/tailwind'
import tokens from '@phcdevworks/spectre-tokens'
const config: Config = {
content: ['./src/**/*.{ts,tsx,js,jsx,html}'],
presets: [createSpectreTailwindPreset({ tokens })]
}
export default configClass recipes are the stable styling API for adapters and apps. They return predictable class strings and keep behavior consistent across frameworks.
import {
getBadgeClasses,
getButtonClasses,
getPricingCardClasses
} from '@phcdevworks/spectre-ui'
const cta = getButtonClasses({ variant: 'primary', size: 'lg' })
const badge = getBadgeClasses({ variant: 'success', size: 'sm' })
const pricingCard = getPricingCardClasses({ featured: true })- Token-driven CSS implementation
- Precompiled CSS bundles and utility classes
- Tailwind helpers and preset generation
- Type-safe class recipes for shared UI contracts
- Stable styling behavior consumed by downstream adapters and apps
Golden rule: consume tokens, do not redefine them.
- Design values or semantic meaning That belongs to
@phcdevworks/spectre-tokens. - Framework-specific component delivery Adapters and apps consume
@phcdevworks/spectre-ui; they do not recreate its styling logic. - Local visual values outside the token contract Hardcoded hex, spacing, or shadow values are drift unless clearly intentional and documented.
The root package exports CSS path constants plus the recipe functions re-exported
from src/recipes/index.ts.
Root constants:
spectreStylesspectreBaseStylesPathspectreComponentsStylesPathspectreUtilitiesStylesPath
Root recipe functions:
getBadgeClassesgetButtonClassesgetCardClassesgetIconBoxClassesgetInputClassesgetPricingCardClassesgetRatingClassesgetTestimonialClasses
Root recipe helper functions:
getPricingCardBadgeClassesgetPricingCardDescriptionClassesgetPricingCardPriceClassesgetPricingCardPriceContainerClassesgetRatingStarClassesgetRatingStarsClassesgetRatingTextClassesgetTestimonialAuthorClassesgetTestimonialAuthorInfoClassesgetTestimonialAuthorNameClassesgetTestimonialAuthorTitleClassesgetTestimonialQuoteClasses
The root package also re-exports the related recipe option, variant, size, and state TypeScript types defined by those recipes.
@phcdevworks/spectre-ui/tailwind exports:
createSpectreTailwindPresetcreateSpectreTailwindTheme
@phcdevworks/spectre-ui/index.css@phcdevworks/spectre-ui/base.css@phcdevworks/spectre-ui/components.css@phcdevworks/spectre-ui/utilities.css
Spectre keeps responsibilities separate:
@phcdevworks/spectre-tokensdefines design values and semantic meaning@phcdevworks/spectre-uiturns those tokens into reusable CSS, Tailwind tooling, and type-safe class recipes- Adapters and apps consume
@phcdevworks/spectre-uiinstead of re-implementing its styling layer
That separation keeps recipe behavior consistent across frameworks and reduces implementation drift.
Install dependencies, then run the package verification flow:
npm run ci:verify
Planning artifacts for contract hardening live in:
Key source areas:
src/styles/for source CSSsrc/recipes/for class recipessrc/tailwind/for Tailwind helperstests/for contract and regression coverageexamples/for visual demos and verification fixtures
Use examples/examples.html as the visual index for
the package demos.
Available examples include:
vanilla.htmlfor the broad component showcaseshowroom.htmlfor a richer marketing-style compositionverification.htmland focused verification fixtures for regression checks
PHCDevworks maintains this package as part of the Spectre suite.
When contributing:
- keep styling token-driven
- keep recipe APIs and CSS classes in sync
- avoid local visual values unless clearly intentional
- run npm run ci:verify before opening a pull request
See CONTRIBUTING.md for the full workflow.
MIT © PHCDevworks. See LICENSE.