• Hygular
  • CSS Framework
  • JavaScript

What Is Hygular? CSS Utilities, Components, and a JavaScript Runtime

Explore Hygular’s layered CSS, reusable components, dependency-free core runtime, and optional React hooks, with a working installation example.

Eyruz Badalzada4 min read

A button needs styles. A dropdown needs styles and behavior. A page needs both to fit the same design system. Hygular brings those concerns into one framework: semantic CSS utilities, reusable component styles, and a vanilla JavaScript runtime, with optional React hooks.

The current core package is @hygular/core. This article describes 1.0.0-beta.2, so treat the examples as a versioned starting point rather than a promise that every API is final.

Three parts, used as needed

Hygular does not require a full JavaScript application just to style a page. You can load its CSS for layout, spacing, typography, colors, and static components. Add runtime behavior where the interface needs it.

PartResponsibility
CSS utilitiesLayout, spacing, typography, visibility, and other reusable rules.
Component stylesShared structures and states for buttons, navigation, forms, dialogs, and other UI.
JavaScript runtimeDelegated interactions, supported lazy components, and component lifecycle management.
React hooksClient-side setup and cleanup for React applications.

These are complementary parts. Component styles are defined in their own layer; they are not merely collections of utility classes. Utilities remain available when a particular layout needs a different arrangement.

Install and load the styles

npm install @hygular/[email protected]

That import is enough for static styling. For example, these controls use the same button component with different variants:

<div class="is-flex gap-3">
  <button type="button" class="button is-primary">Save changes</button>
  <button type="button" class="button is-ghost">Cancel</button>
</div>

Add an interaction

For a regular browser application, initialize the runtime after its markup is available:

import { Hygular } from '@hygular/core';

const app = new Hygular();

// Call app.dispose() when the application shell is removed.

The trigger declares its behavior and identifies a target. The runtime handles the interaction. This is useful for server-rendered pages and applications where ordinary HTML remains the main interface between content and behavior.

Automatic initialization has a defined scope. The lazy registry includes swiper, badge, tabview, tooltip, popover, and range. Modal, Toast, and other APIs also support direct use; importing the package does not create every component automatically.

Use a component directly

You can show a toast without constructing the full runtime:

import { Toast } from '@hygular/core';

const notification = Toast.show({
  message: 'Changes saved.',
  status: 'success',
});

// If its owning view is removed before automatic dismissal:
// notification.dispose();

Direct instances belong to the code that creates them. A separate Hygular instance does not automatically own or dispose every component elsewhere in the application.

Core, compiler, and scaffolder are separate

@hygular/core supplies the framework. @hygular/cli is a separate CSS compiler and watcher. @hygular/create-app is a separate project scaffolder. You do not need the compiler or scaffolder to use the distributed core stylesheet.

The core JavaScript runtime has no mandatory runtime dependencies. That statement does not describe the build tools, the compiler, or React itself. React integration uses React as an optional peer dependency.

Where Hygular fits

Hygular is worth evaluating when you want reusable component behavior alongside utility CSS and prefer direct HTML attributes or small component APIs. It also gives React applications an integration path without making React a requirement for other consumers.

It does not provide application routing, authentication, a backend, or a content model. Those remain application decisions. Before adopting the beta, exercise the components you need in your supported browsers and test the actual production build.

Continue with Getting Started, or read about using Hygular with React and Next.js.

Hygular