DarkWiiPlayer/CSS WIP

A modular 📦 CSS framework & component library

(Still very much work in progress)

Get Started!

DarkWiiPlayer/CSS

DarkWiiPlayer/CSS is a small CSS component library or "framework" that aims to provide good enough styling when just dropped into an existing website along with a collection of opt-in styles and utility components.

Features

Getting Started

DarkWiiPlayer/CSS is a collection of plain CSS files that can easily be loaded from a CDN or served directly without any compilation or pre-processing steps.

Import from CDN


@import
	url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/all.css')
	layer(framework);
@import
	url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/schemes/talia.css')
	layer(theme);
			

Or serve the files yourself from a git submodule

Clone into your project


git submodule add git+https://github.com/darkwiiplayer/css /path/to/styles
			
Warning Layers

The all.css file makes use of import statements with layers, which have less than ideal support in some CSS preprocessors. If something is broken, check that any bundled CSS is actually importing the files correctly.

Layout

Flex Containers

Simple flex containers can be created using the <flex-column> and <flex-grid> custom elements.

  • The gap attribute can be used to set the CSS gap attribute on the container to space items.
  • The reverse attribute, when present, reverses the flow of the flex items.
  • The wrap attribute controls the minimum viewport width below which a flex-row will turn into a column.
  • Refer to flex.css for possible values of these attributes.

Row

Use flex-row to arrange items horizontally.

1
2
3
4
5

Column

Use flex-column to arrage items vertically in a column.

1
2
3

Flex-Grid

Use flex-grid to arrange items into a grid using display: flex.
This allows for a more out-of-the-box responsiveness than the more specialised display: grid used in the grid-box element.
Use this element when you want to keep column-width consistent across resolutions. grid-box element.

  • The columns attribute describes the target column count at a reference width.
    • The value 6@1920, for example, means that at 1920px available space, the grid should have 6 columns.
    • The value 3@content means that at the default width of an <article> the grid should have 3 columns.
  • gap acts the same as with the other flex and grid layours.
  • The --column-width can be used to specify a fixed column width.

1
2
3
4
5
6
7
8
9

Grid Containers

Use <grid-box> to create native CSS grids with display: grid.
Use this element when you want to keep column-count consistent across resolutions.

  • The columns attribute sets a fixed number of columns for the grid.
  • The gap attribute works exactly like for flex containers.
  • The wrap attribute works like for flex-grids.
1
2
3
4
5
6
Warning

Native CSS grids are relatively static in their layout and not as suited to generic responsive layouts. For grids with dynamic column counts, use flex-grid instead.

Layout Helpers

  • Only Mobile: The only-mobile custom element and the .only-mobile class will hide an element on dipsplays wider than 500px
  • No Mobile: Similarly, the no-mobile element and class hide elements below this resolution.
  • No Desktop: The element and class no-desktop hide elements at screen widths above 1500px.
  • Only Desktop: The only-desktop class and element are hidden at any smaller screen-width.
  • Only Portrait: The only-portrait class and element are hidden in landscape aspect ratio.
  • Only Landscape: Likewise, only-landscape are hidden in portrait aspect ratio.
  • Full Width: The .full-width class sets an elements width to 100%.
  • Vertical overflow: The classes .scroll-x and .hidden-x set the overflow-x attribute of the element.
  • Horizontal overflow: The classes .scroll-y and .hidden-y set the overflow-y attribute of the element.
  • Rounded Corners: The .round class sets an elements border-radius to the --border-radius variable.

Components

Badge

Badges are a generic way of adding short (usually one-word) tags to the document.
They are colourful and attract attention, and should therefore be used carefully and sparingly.
Use them to display informationt hat might be of priority to a user.

Usage examples

Adding entity counts

Users 315

Listing short tags

An Article about CSS
Tags: #Beginner #Tutorial #CSS

Blob

The .blob utility class makes an element blob-shaped and fixes is aspect-ratio to 1 / 1.

There are 9 different blob-shapes which will be picked based on the element's child count inside its parent element. To manually set the shape of a blob, the classes .blob-1 through .blob-9 are available. The CSS file also exposes the --blob-1 through --blob-9 custom properties which can be used in an elements border-radius property to make it blob-shaped.

Box

Boxes are the main generic container element. By default they appear inset into the document. This can be changed by also adding the floating class which will elevate the box from the document.

Boxes can also have a coloured bar at their right edge to make them more attention seeking and help distinguish them vertically from their surrounding content.

Boxes also take their corner radius from the --corner-radius variable.

Content in a box
Content in a box

Button

Buttons, button-like input elements and anchors (links) with the button class all have the same styling.

Buttons can be grouped using the button-group custom element

Drawer

Drawer elements are used to hide content from the page like a navigation menu.

Open

Click anywhere outside the drawer to cose it again.

TODO

Script-controller drawers are not currently supported.

Floating Action Button

The floating-action-button custom element can be used to position an element in one of the corners of its parent element. The button itself will still have to be styled separately though.

Content in a box, button in the bottom right.

Hero

The page-hero custom element is a large, full-width box at the beginning of the page.

Items in the hero section are arranged as a centered column. Items are centered vertically and horizontally. A single image that's the first child element of the hero section will be displayed as a background image to the box.

The minimum height of the page hero can be adjusted using the cover attribute, which currently supports values in % of screen height from 40 to 100 in steps of 10. Developers should generally aim to keep content within this range and avoid growing the hero beyond its intended size.

A special rule makes full-height hero elements preceded by a header shorter by the value of --header-height to ensure that both elements combined will cover the sreen entirely.

Please note that this element only provides a good baseline for a generic hero section. It does not cover (nor could it) any more elaborate design, but should still provide a good foundation to add more interesting styling on top of.

Lists

Ordered

  1. First list item
  2. Second item on the list
  3. Third thing being listed

Unordered

  • First list item
  • Second item on the list
  • Third thing being listed

Spacers

Vertical and Horizontal spacing can be added where needed using the vertical-spacer and horizontal-spacer custom elements. Adding the attributes double, triple and quadruple increases the spacing.

Tables

Basic HTML tables work out of the box.

GreetingName
HelloWorld
GreetingsInternet

Vertical tables also work

NameTalia
HobbiesWriting CSS

Lines can be added with the borders attribute:

  • horizontal adds horizontal ilnes
  • vertical adds vertical ilnes
  • outline adds a border around the table
When the attribute is missing entirely, horizontal borders will be used.

Tables without horizontal lines will have every second row slightly lightened/darkened for easier reading. This can be enabled explicitly by setting the alternate attribute to rows and disabled by setting it to anything else (including the empty string).

GreetingName
HelloWorld
GreetingsInternet
GreetingName
HelloWorld
GreetingsInternet
GreetingName
HelloWorld
GreetingsInternet
GreetingName
HelloWorld
GreetingsInternet

Other built-in elements

Many other common HTML elements have received smaller styling changes.

Code

						Hello, World!
					

Details

Summary of the subject

Further explanation on the subject.

The dim-open class will become transparent when the surrounding details element is opened. Put this on a span to prevent the indicator from becoming transparent too.

With "slidy" details elements, the indicator slides down to guide the user's attention to the beginning of the revealed content.

"Slidy" has limited support due to @scope usage.

Slidy?

Read this!

Quotes

This is a paragraph with an inline quote.

As a very dumb person once said:

This is a longer quote with a citation at the bottom.

Me, just now

Forms

Forms & form elements work out of the box and support tab navigation by highlighting focussed elements.


Size
Hint

You can use flex-row elements to break elements out of the two-column layout.

Typography