Getting Started
Hygular combines semantic utility CSS, reusable component styles, and a dependency-free JavaScript runtime. Use the stylesheet alone for static interfaces, then add the interactions your application needs.
This guide targets @hygular/[email protected]. APIs may change during beta.
Install
npm install @hygular/[email protected]
Load the stylesheet
Import the stylesheet once in your application entry point or global layout.
import '@hygular/core/css';
Utilities and static component styles work without JavaScript.
<div class="is-flex gap-3">
<button type="button" class="button is-primary">Save</button>
<button type="button" class="button">Cancel</button>
</div>
Initialize the browser runtime
Initialize one runtime after the page markup is available. For CDN usage, place these scripts before the closing body tag.
import { Hygular } from '@hygular/core';
const app = new Hygular();
// When the application shell is removed:
// app.dispose();
Hygular is a named ES module export and the constructor exposed by the UMD bundle on window. The npm package name is @hygular/core; it is not the browser global name.
The runtime registers delegated interactions, observes supported lazy components and deferred images, and watches inserted DOM nodes. Its lazy registry covers swiper, badge, tabview, tooltip, popover, and range. It does not automatically instantiate every exported component.
Declarative interactions
<button type="button" class="button" data-hygular-toggle="collapse" data-target="#details">
Show details
</button>
<div id="details" class="collapse">Additional information.</div>
Use data-hygular for supported component roots, data-hygular-toggle for delegated triggers, and the component-specific attributes documented on each page.
Direct component APIs
Named component exports can be used without a full runtime instance.
import { Toast } from '@hygular/core';
Toast.show({ message: 'Changes saved.', status: 'success' });
Components created directly remain owned by your application. Dispose of them when appropriate; app.dispose() only cleans up the handlers and lazy instances tracked by that runtime.
React
Import hooks from @hygular/core/react. No package-provided context provider is required.
'use client';
import { useToast } from '@hygular/core/react';
export function NotifyButton() {
const toast = useToast();
return (
<button className="button is-primary" onClick={() => toast.success('Changes saved.')}>
Notify
</button>
);
}
Import the global stylesheet separately. Use hooks or manual initialization for a given element, with one owner for its lifecycle. See React Integration for delegated and element-bound hooks.
Optional CSS compiler
@hygular/cli is a separate development dependency. Use a release compatible with @hygular/core when you need source scanning and generated CSS.
npm install -D @hygular/cli
The executable remains hygular. The default output is public/hygular.build.css; load it instead of the full stylesheet. See Compiler Engine for configuration and scanning limits.
Package entry points
| Path | Contents |
|---|---|
@hygular/core | Runtime and named component exports |
@hygular/core/react | React hooks and declarations |
@hygular/core/css | Minified CSS for direct use |
@hygular/core/css/source | Unminified compiler input |
@hygular/core/css/source is an export alias for dist/css/hygular.css, not a separate directory. Its breakpoint placeholders are resolved during compilation.