Granum v2.4.0

Developer Documentation

1. Getting Started

Include the CSS and JS files in your HTML. The JS file is optional but recommended for progressive enhancements.

<link rel="stylesheet" href="granum.min.css">
<script src="granum.min.js" defer></script> <!-- optional -->

It is possible to include core styles and icons separately or skip icons completely.

<link rel="stylesheet" href="granum.core.min.css">
<link rel="stylesheet" href="granum.icons.min.css"> <!-- optional -->
<script src="granum.min.js" defer></script> <!-- optional -->

To make a page mobile-friendly and responsive, include the viewport meta tag into the <head>.

<meta name="viewport" content="width=device-width, initial-scale=1">

2. Layout & Grid

Flexbox Rows

Use .row for horizontal layouts. Add .wrap to allow wrapping, and .gap for spacing.

Row options:
Column 1:
Column 2:

Column 1
Column 2
Text
Text
Text
Text

Auto-Filling Grid

Use .grid-* to create responsive grids that automatically fill available space based on minimum cell widths.

Column width:
Third column span:

Cell 1
Cell 2
Cell 3
Cell 4

Columns

Use .columns-* for columns.

Column width:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tristique purus nec erat suscipit, eget rhoncus ipsum porta. Donec ut enim quam. Nulla neque purus, convallis eget justo vitae, aliquam hendrerit velit. Mauris metus tortor, eleifend id nibh quis, maximus pharetra ante. In auctor neque vitae ultrices sagittis. Aliquam posuere purus ac vulputate commodo. Quisque aliquet velit in sem aliquet laoreet.

Stack

Use .stack to avoid outer margins. Use .stack.line to add borders between items.

Container style:
Stack style:

Paragraph 1

Paragraph 2

Paragraph 3

Stick

Use .stick to stick an element to the top or bottom.

Header
Article

p

p

p

p

p

p

Footer

Splitter

Use .resize on child nodes of the same .row container.

Container styles:

Left column
Table
Value
Some very long text written to trigger horizontal scroll
Center
column
Right column

3. Typography & Content

Basic Elements

Text Link Unlink Bold Strong Italic Emphasis Ins Del Mark
Code Kbd Quote Cite Definition Small Abbr xsub xsuper


Block quote
Preformatted text
Code: var = value

Text

Spacing


Maximum width:

Div
Div
Div

Paragraph

Paragraph

Links and Buttons

Images

Figure caption

Tags, badges, progress

Tag Border Info Bg 1 Invert Small 8

Link 1 Link 8 Link 5

30% Default
40% Neutral
50% Note
60% Info
70% Success
80% Warning
90% Danger

Table

Style options:

Name Number Date String
Alice001.07.2000Coffee
Ben10002.02.2000Water
Charlie-2201.07.2025Juice
Dan1501.12.2024Tea
Total 93

List

Style options:

Before After

Pagination


Breadcrumbs


Card

Header
Contents
of
card
Footer

4. Colors & Theming

Semantic Colors

Apply contextual colors to text, backgrounds, or borders using utility classes.

Default Note Information Success Warning Danger
Link Neutral Note Information Success Warning Danger
Link with icon Colored link with icon Colored icon only

Dark Mode

Invert the entire page or just specific element. Enable dark mode in your browser or OS. Or check the following checkboxes.



Example Info Link Bord Shade
TableInfo

5. Forms & Inputs

Grid Forms

Use .form.resp for aligned, responsive form layouts.

Form options:
Button position:
Button style:



Form validation

Inside .form, use .tip > .success, .tip > .danger after input for tips.
Use .form.lazy to show tips only after user interaction.
Use button.detect to enable the button only if the form is valid.

Validation mode:

Required OK
[] Hint: Incorrect e-mail OK

Checkboxes & Switches




Custom Select

Enhanced with JavaScript

Customized dropdown <select>-like input using [popover] and radio buttons.
JavaScript sets focus after opening, copies value to button's first span text and closes popover after selection, enables filtering.

Button options:
Popover options:
List options:
Label options:
Radio options:



Required

Customized Inputs

Use .input wrapper for composite input.
Use .dropzone for file input to turn it in a drop zone.

INCORRECTOK

Input Types

Container options:

Contenteditable...

6. Interactive Components

Dropdown navigation

Style options:
Transition:

Modals & Drawers

Pure CSS, no JavaScript required. Requires Invoker Commands API. Closes on Escape key, command button, or click outside. Has styleable ::backdrop. Traps focus. Autofocus. Nestable. Appearance transition. Show in hash :target match (with JS).

Mode of dialog:
Transition:

Dialog content

Scrollable Dialog Example

Scrollable Dialog

Mode of dialog:

Modal Title

This is a pure CSS modal triggered by the URL hash.

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

p

Popups

Transition:

Use [popover].

Tooltips

This is a tooltip
This is an inverted animated tooltip

Tabs

Enhanced with JavaScript

Controlled via hash links.

This is the content for Tab 1.
This is the content for Tab 2.

Toggle content with :checked

Use .check on the label or checkbox to toggle the following element.

Target content

...
Target content

Toggle content with :target

Enhanced with JavaScript

Use .target on target element. Add .act on link for initially opened state. Add .mem on target element for state persistance. Add .toggle on hash link for JS enhancements (toggle off and avoid page jump).

Show target
Target content 1
Close

Show target (enhanced)
Target content 2
Close

Slider with :target

One
Two
Three
Four

Gallery

Enhanced with JavaScript

Gallery (pure CSS)
Gallery (pure CSS, no container)
Red Green Blue Grey Gallery (with JS enhancements: previous, next, Escape key)
Legacy Modals, Popups and Tooltips

Modals & Drawers with :target

Deprecated

Triggered via URL hash fragments. Pure CSS, no JavaScript required!

Open Modal Open Fullscreen Open Drawer

Popup disclosure

Using native <details> elements.

Before
Options ▾
After

Popups on hover

Enhanced with JavaScript

Using a :hover state. Add .pos for automatic positioning with JS.

Style options:

Before
Default
Info
Text
Nested
More info

p

p

p

p

p

p

p

p

p

p

p

p

After.

Tooltips with [data-hint]

Deprecated

Hover over me Or me

7. Utilities

Visibility

Hidden
Revert element's display to default (block for div)

Responsive Display Toggles

Show/hide elements based on viewport or .container width. Resize your browser window or container to see them appear/disappear.

Viewport: Not large Large Not medium Medium Not small Small
Container: Not large Large Not medium Medium Not small Small

JavaScript detection

Show/hide elements based on JavaScript availability.

JavaScript disabled
JavaScript enabled

Printable

Hide elements when printing.

This will not be printed

8. Icons

Compact icons using mask-image

Icons animation

Animation type:

Icons toggle

Some icons switch in active mode (.act, :has(+:target), .check:has(:checked), [open]>summary). Click icons to toggle.


Content Close
Content
Content
SummaryDetails

9. JavaScript Functionality

Requires JavaScript

Dynamic Class Toggling ([data-nodes])

Toggle CSS classes on target elements based on input state.

Serif
This div will get 'success', 'bord', 'shade', 'serif' classes when checked

Toggle sub-list (#open)

Style options:

List filtering

Add .keep to a list item to exclude it from filtering.

Emits granum-filter event.

Table Sorting & Filtering

Click the headers to sort, or type in the search box to filter.

Add .keep to a row to exclude it from filtering.

Emits granum-filter and granum-sort events.

Name Number Date String
Alice001.07.2000Cafe
Dan150.50 km2024-12-01café
ben150.15 km02.02.2000café
Charlie-227/1/2025coffee
No
name
-

Dialogs

Confirm Prompt

State Persistence (.mem)

Type something below, then refresh the page. Input values and details state are saved to the localStorage.


Show details The details

Populate inputs from URL ([data-get])

Click to populate or clear inputs.


Check multiple boxes

Manage Items

Operates on closest div, ul, tr parent by default. To override, define selector in [data-item] (for closest parent) or in [data-src] (global selector). To keep at least one item, add .keep to the #item-del link.

Emits granum-manage event.

Add item as a copy of hidden <li>.

Drag Items

Use .drag-container, table, ul as container, .drag-item for items, and a[href="#drag"] for handler. For correct work on touch devices, .drag-container is strictly required.

Emits granum-drag event.

One
Two
Three
One
Two
Three

Copy input value

Copy
Text to copy Copy

Show password

Show

Synchronize textarea and contenteditable

Go back

Back

10. Events

All granum-* custom events bubble and are cancelable.

Filter

Occurs after filtering a list or table.

type
granum-filter
target
Items container (list or table)
detail.query
Filter string
detail.found
Matching items count

Sort

Occurs after sorting a table.

type
granum-sort
target
Sorted column header
detail.order
1 for ascending, -1 for descending

Drag

Occurs after applying a drag sort.

type
granum-drag
target
Items container
detail.item
Dragged item

Manage

Occurs after managing items.

type
granum-manage
target
Items container
detail.action
Action (del for delete, up for move up, down for move down, copy for create a copy)
detail.item
Managed item (for copy action contains source item)
detail.copy
Created item (only for copy action)

Customize style

p









Top Cancel