Granum v2.4.3

Developer Documentation

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">

Layout & Grid

Flexbox Rows

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

Wrapper:
Row modifiers:
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.

Wrapper modifiers:
Stack modifiers:

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.

Wrapper:
Row modifiers:

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

Spacing


Maximum width:

Div
Div
Div

Paragraph

Paragraph

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

Sans serif Serif Monospace Small Regular-size Bold Middle

Align left
Align center
Align right

No auto wrap. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tristique purus nec erat suscipit, eget rhoncus ipsum porta.

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

Modifiers:

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

List

Modifiers:

Before After

Pagination

Breadcrumbs


Card

Header
Contents
of
card
Footer

Colors & Theming

Semantic Colors

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

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

Forms & Inputs

Grid Forms

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

Wrapper:
Form modifiers:
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




Floating Labels

For floating labels, put input (or textarea) and label inside .input and add single space placeholder.

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.

Modifiers for complex select:
Button modifiers:
Popover modifiers:
List modifiers:
Label modifiers:
Radio modifiers:








Required

Customized Inputs

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

INCORRECTOK

Input Types

Wrapper modifiers:

Contenteditable...

Interactive Components

Dropdown navigation

Wrapper:
Modifiers:
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.
Second line.

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, avoid page jump, optionally restore state with .mem).

Show target
Target content 1
Close

Show target (enhanced)
Target content 2
Close

Slider with :target

← One →
‹
Two
›
Three
Four

Gallery

Enhanced with JavaScript

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 details

Using native <details> elements.

Before
Options ▾
After

Popups on hover

Enhanced with JavaScript

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

Modifiers:

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

Utilities

Visibility

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

Responsive Visibility

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
Wrapper: 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

Icons

Iconset using mask-image

Modifiers:
Color:
Animation:

Icons animation

Animation:

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

JavaScript Functionality

Requires JavaScript

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)

Modifiers:

List filtering

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

Emits granum-filter event.

  • 1 One
  • 2 Two
  • 3 Three
  • 4 Four
  • 5 Five: keep

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 Checkboxes

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.

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
One
Two
Three

Copy input value

Copy
Text to copy Copy

Show Password

Synchronize Textarea and Contenteditable

Go Back

Events

All granum-* custom events bubble and are cancelable.

Filter list or table

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 table

Occurs after sorting a table.

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

Drag item

Occurs after applying a drag sort.

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

Manage items

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