Specs JavaScript API definitions for semantic component interpretation file-text API Reference
Categories

Specs

@semantic-ui/specs provides tools for defining and interpreting component APIs. It enables semantic HTML parsing, documentation generation, and bidirectional transformation between HTML and component metadata.

Installation

Specs can be used as a standalone package or alongside Semantic UI components.

Terminal window
npm install @semantic-ui/specs

Basic Usage

import { SpecReader } from '@semantic-ui/specs';
import buttonSpec from './button.spec.js';
const reader = new SpecReader(buttonSpec);
// Generate runtime metadata
const componentSpec = reader.getWebComponentSpec();
// Parse semantic HTML
const parts = reader.getComponentPartsFromHTML(
'<ui-button primary large>Save</ui-button>'
);
// Generate HTML from modifiers
const html = reader.getCodeFromModifiers('primary large', {
html: 'Save',
});

API Sections

Core

Documentation Generation

Semantic Interpretation

Utilities

Previous
Base Class
Next
SpecReader