Introduction

The goal of this CSS reference is to show you the bricks provided by the framework to design your application. Then with the inspector for your browser (right-click on an item) you can pick-up the classes and DOM structures needed.

This bootstrap cover 80% of main needs, you can write an other CSS file for the rest of your project or try to reuse those 80% as much as possible.

CSS variables are used for colors and spacing (padding and margin) to have a single point to update.

Very often inline elements have relative size to the font size, so a button will be bigger if the paragraph which contains it is bigger.


.f1 or h1

.f2 or h2

.f3 or h3

.f4 or h4

.f5 or h5 (default, 1rem, 16px)

.f6 or h6

.f7 (very small and dense)


Text

Text alignment

.text-left

.text-right

.text-center

Text utilities

.text-ellipsis This is a long text which will be truncated. This is a long text which will be truncated. This is a long text which will be truncated.

.text-no-select Impossible to select, useful to remove from copy/paste selection or apply on buttons

.text-light Makes small fonts more readable in some situations

Text measure

.measure-narrow Anything from 45 to 75 characters is widely regarded as a satisfactory length of line for a single-column page… the 66-character line (counting both letters and spaces) is widely regarded as ideal. For multiple-column work, a better average is 40-50 characters.

.measure Anything from 45 to 75 characters is widely regarded as a satisfactory length of line for a single-column page… the 66-character line (counting both letters and spaces) is widely regarded as ideal. For multiple-column work, a better average is 40-50 characters.

.measure-wide Anything from 45 to 75 characters is widely regarded as a satisfactory length of line for a single-column page… the 66-character line (counting both letters and spaces) is widely regarded as ideal. For multiple-column work, a better average is 40-50 characters.


Text colors

All colors of the framework are available with their name directly.

.primary

.success

.warning

.danger

.black

.gray-darker

.gray

.white


Background colors

All text colors are available as background colors with the prefix bg-*, more grays are available to allow layout visual partitions.

.bg-primary

.bg-success

.bg-warning

.bg-danger

.bg-black

.bg-gray-darker

.bg-gray

.bg-gray-light

.bg-gray-lighter

.bg-white


Buttons

The .btn class is designed to be used with <button> elements. Buttons can have different states: .active, .selected, .loading (class name) and disabled (HTML attribute).

Five colors are available, .btn might be used everywhere, .btn.btn-primary for main buttons, .btn.btn-danger for destructive actions

, .btn.btn-success for confirmatory actions

, .btn.btn-warning for worrying actions.

Normal:

Active:

Disabled:

Loading:

Group buttons together:

Tabs:

Menu:

Item 1 Item 2 Item 3 Item 4

Dropdown:

Dropup:

Tooltip:

Hooray!

Switch Toggle:

link to external website

Badges

The .badge class can be used to emphasize a field. It can be used together with all background and font classes:

10
50
100


Form inputs

Forms are a way to have user inputs in addition to buttons. Always put a <label> tag with a for attribute associated to the id of the <input> it is targeting. It helps the user to click, especially for checkboxes which are small. <form> tag is not useful in single page application, except for a reset button which needs it.


Table

Add the base class .table to any <table>

# First Last Handle
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter

Add .table-sm to make tables more compact by cutting cell padding in half.

# First Last Handle
1 Mark Otto @mdo
2 tr.table-primary tr.table-primary tr.table-primary
3 Larry the Bird @twitter

Radius

A simple way to modernize an app is to put some radius, it feels less raw and more elegant without designer skills.


Display

The display specifies the type of rendering box used for an element.

.d-none (will turn off the display of element and its children)

.d-inline (span default behavior)

.d-inline-block (button, img, input default behavior)

.d-block (div default behavior)

inline inline inline
block
block
block

Effects

Increase user experience and awareness with effects.

.highlight will flash the background in yellow, once

.spin-around will rotate 360° the item, forever.

.appearance will show the item slowly, once


Levels

Levels is a way to elevate contents and stack them, for example a menu is above the rest of the page which scrolls below. See Material Design.

.shadow-level0 for content (z-index and shadow)

.shadow-level1 for card of content

.shadow-level2 for topbar

.shadow-level3 for dropdown menu

.shadow-level4 for notification

.level0 (only z-index)

.level1

.level2

.level3

.level4


Position

Specifies the type of positioning method used for an element and can be enhanced with some attributes (top, left, bottom, right).

.relative is positioned relative to its normal position

.absolute is positioned relative to the nearest positioned ancestor

.absolute-fill will fill completely its nearest parent which has .relative


Flex

Flex is the defacto way to manage the layout and alignment. For example, it makes easy to split the view in both content and sidebar or arrange many items in a container.

.flex-row

.p1.m1
.p1.m1
.p1.m1

.flex-row

.p1.m1
.p1.m1
.p1.m1.flex-grow

.flex-row

.w-100.p1.m1
.w-100.p1.m1
.w-100.p1.m1

.flex-column

.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1

.flex-wrap

.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1

.flex-wrap.justify-center

.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1

.flex-wrap.justify-between

.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1

.flex-wrap.justify-around

.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1
.w-33.p1.m1

.flex-row.items-start

.w-100.p1.m1
higher
higher
.w-100.p1.m1
.w-100.p1.m1

.flex-row.items-end

.w-100.p1.m1
higher
higher
.w-100.p1.m1
.w-100.p1.m1

.flex-row.items-center

.w-100.p1.m1
higher
higher
.w-100.p1.m1
.w-100.p1.m1

.flex-row.items-baseline

.w-100.p1.m1
higher
higher
.w-100.p1.m1
.w-100.p1.m1

.flex-row.items-stretch

.w-100.p1.m1
higher
higher
.w-100.p1.m1
.w-100.p1.m1

Scroll

This should always be applied to layouts before content to avoid overflow.

.scroll-y only show vertical scroll bar (recommended)

.scroll-auto add scroll bars if needed

.scroll-off just hide all overflow

<div class="absolute-fill scroll-y">
    <p>
      Very long text that should be scrollable if window is too small
      ...
    </p>
</div>

Width

Main widths used to cut a view: full view (100%), 2 parts (50%), 3 parts (33%) and 4 parts (25%). More than this begins to be difficult to read.

The current documentation use a 25% sidebar and a flex-grow content for the rest (75%).

.w-25

.w-33

.w-50

.w-75

.w-100


Spacing (padding, margin)

Provides a spacing scale based on powers of two that starts at .25rem (for most devices this will be the equivalent of 4px).

Always use the same spacing for two contents that should be aligned (margin value of a button above a text with same padding value).

Padding all

.p1
.p2
.p3
.p4

Padding horizontal

.ph1
.ph2
.ph3
.ph4

Padding vertical

.pv1
.pv2
.pv3
.pv4

Margin all

.m1
.m2
.m3
.m4

Margin horizontal

.mh1
.mh2
.mh3
.mh4

Margin vertical

.mv1
.mv2
.mv3
.mv4

App layout

Main app layout with navbar, menubar and its content.

Title

Sidebar Actions

Example of basic layout with toolbar and one sidebar.

The sidebar can be closed with .sidebar-closed and the layout is free. In the current example the menu is inside a scrollable container but we could imagine the sidebar to be split in half to preview some element at the bottom and have a menu at the top.

Sidebar can also grow is more place is needed, use .sidebar-extend or just specify the width you want with a style attribute.

Sidebar can also be used in a minimal iconic way if needed, use .sidebar-minimal

Only flex (.flex-row or .flex-column with .flex-grow) and position (.relative and .absolute-fill) are required for most of your needs.

.scroll-y should be applied to layouts before content.


App loading

This component contains a spinner, a text and a layout to put the content in the middle of the screen.

Loading...

Notification

Notification informs user of an event without blocking interaction like alert().

Notification has 3 states: initial (not displayed), opened (shows with animation) and closed (hides with animation). Because of its absolute position, it should be placed on a top element inside body. In the following example, its position is absolutely relative to the gray area.

Server connection has been lost. Please reload page.

Icons

You can use icons inside text, they will adapt to the font size with the 'icon' class. Choose the right one then put the mouse on top of it to get the icon name, the name is the function to call inside javascript to produce an hyperscript equivalent.

import {h} from '/js/src/index.js';
import {iconZoomIn, iconZoomOut} from '/js/src/icons.js';

  function view(model) {
    return [
      h('button', {onclick: () => model.zoomIn()}, iconZoomIn()),
      h('button', {onclick: () => model.zoomOut()}, iconZoomOut()),
    ];
  }