logo

Mg+

v1.3.4

A micro CSS library

Build pretty websites with just a few drops of CSS

Getting started Download Github
CSS variables
Dark mode
Fully responsive
Lightweight

Why Mgplus ?

Mgplus is specially designed to quickly create a website or a small page with minimal dependencies for better performance and higher productivity

Mg+ (Milligram Plus) was conceived as an enhancement to the Milligram CSS framework : Milligram

The project began in early 2021 with the goal of providing a more robust and feature-rich alternative while maintaining the minimalistic approach of Milligram.

The project has seen multiple releases, each aimed at improving performance, flexibility, and ease of use.

Core concepts

Mg+ is designed to be simple and intuitive. Here are some core concepts to keep in mind:

Library size comparison

Milligram v1.4.1
8 KB
Mg+ v1.3.3
68 KB
Bootstrap v5.3.0
163 KB
Bulma v0.9.4
163 KB
UIkit v3.7.0
256 KB

Components

Mg+ comes with a range of features to help you build beautiful websites quickly and easily. Some of the key features include:

Utilities

In addition to components, Mg+ provides a set of utility classes to help you quickly style your elements. These include:

Getting Started

To get started with Mg+, include this CSS file from our CDN in your project and start using the predefined classes to style your elements. You can also customize the styles to fit your needs.

Quick start (statics websites)

To quickly get started with Mg+, follow these steps:

  1. Include the Mg+ CSS file in the <head> section of your HTML file to apply the default styles:
  2. <link rel="stylesheet" href="https://cdn.mgpluscss.com/v1.3.4/css/mgplus.css">
  3. Start using the predefined classes in your HTML elements. For example, to create a button, you can use:
  4. <button class="mg-button">Click me</button>

Customizable css variables

To customize Mg+ variables, just override the root variables. For example:

:root {
    --mg-primary-color: #3498db;
    --mg-secondary-color: #2ecc71;
    --mg-control-radius: 1.5rem;
    --mg-input-radius: 1.5rem;
    --mg-control-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.2);
}

JS Plugin configuration (optional)

For interactive components like dropdowns, tabs, modals, etc. You can include the Mg+ JS file in your project to enable these features. The JS file is optional and can be included based on your requirements.

This vanilla plugin could be replaced easily by another JS UI Framework like : Angular, React, Vue, Svelte, Solid, etc.

Default configuration

By default, all available plugins are registered

<script src="https://cdn.mgpluscss.com/v1.3.4/js/mgplus-dom.js"></script>

Custom configuration

Register only specific plugins by using inline query param

<script src="https://cdn.mgpluscss.com/v1.3.4/js/mgplus-dom.js?register_plugins=dropdowns,tabs,modals,collapses"></script>

To allow plugin works for your mgplus css components Add html attribute data-toggle=["plugin_name"] in your html components

Example:
<div class="mg-dropdown">
        <button title="choose a car" class="mg-icon-dropdown" data-toggle="dropdown">
            Choose a car
        </button>
        <div class="mg-dropdown--content">
            <div class="mg-nav">
                <ul>
                    <li data-value="audi">Audi</li>
                    <li data-value="bmw">BMW</li>
                    <li data-value="toyota">Toyota</li>
                </ul>
            </div>
        </div>
    </div>

List of available plugins

Configure DarkMode

In your main html document page, add attribute data-theme="dark" or data-theme="light" or data-theme="auto"

<html lang="en" data-theme="auto">...

"auto" mode will use your system browser preference to choose dark or light mode

Js extensions are required only to handle interactions with dom events for navs, tabs, dropdowns, modals, etc. It could be replaced by creating a wrapped UI components with react, angular or other any UI framework

Examples

Explore the various examples provided in the documentation to see how you can use Mg+ to build your web interface. Each example demonstrates the usage of different components and utilities to help you get started quickly.

We hope you find Mg+ useful and easy to work with. Happy coding!

Base elements

These elements include typography, colors, and other basic components that are used throughout the application.

Typography

The base type is 1.6rem (16px) over 1.6 line height (24px)

Anchor Emphasis Small Strong Underline

Heading h1

Heading h2

Heading h3

Heading h4

Heading h5
Heading h6
Text Text Text Text Text Text Text Text

Blockquotes

Yeah!! Milligram is amazing.

Buttons

Default Button

Lists

  • Unordered list item 1
  • Unordered list item 2
  • Unordered list item 3
  • Unordered list item 4
  1. Ordered list item 1
  2. Ordered list item 2
Description list item 1
Description list item 1.1

Tables

Name Age Height Location
Stephen Curry 27 1,91 Akron, OH
Klay Thompson 25 2,01 Los Angeles, CA

Codes

        
          {
            "jsonSample": true,
            "jsonObject": {
              "jsonKey": "jsonValue"
            },
            "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam, voluptate.",
          }
        

Alert

Alerts are used to display important information to the user. They are used to display important information to the user. They are used to display important information to the user.

This is an default alert box.
This is an danger alert box.
This is an success alert box.
This is an warning alert box.

Badges

Badges are used to display important information to the user. They are used to display important information to the user. They are used to display important information to the user.

Default appearance

default danger success warning

With custom text sizing

default danger success warning

Check

You will find examples of checkboxes in their default, checked, and disabled states.

Collapse

Collapsible elements are used to hide or show content based on user interaction. Below, you will find examples of collapsible elements in their default state, as well as examples of how to trigger the collapse and expand functionality.

Collapse needs js to toggle class visibility
Content 1
Collapse div
Content 2

Collapsible navs

Colors

These colors are used to create a cohesive and visually appealing design. Below, you will find examples of how to use these colors in various elements and components.

mg-bg-primary
mg-bg-secondary
mg-bg-tertiary
mg-bg-quaternary
mg-bg-quinary

Darkmode conditional hidden colors (hidden when light or dark)

mg-hidden-dark mg-hidden-light

Basic colors

mg-bg-red
mg-bg-orange
mg-bg-blue
mg-bg-green

Forms

Forms are used to collect user information and submit it to the server. Below, you will find examples of form elements in their default state, as well as examples of how to trigger the form functionality.

Responsive Grids

Grids are used to create a responsive layout for the application. Below, you will find examples of how to use the grid system to create a variety of layouts.

Row sizing and placement
x4
x3
x2
x1
x6
x12
x6 offset3
x6 start
x6 end
Responsibve Row sizing
x6
s12
m12
l12
Row alignment
start
x4
x3
x2
x1
center
x4
x3
x2
x1
end
x4
x3
x2
x1
Col alignment
top
x4
x4
middle
x4
x4
bottom
x4
x4
Row grow
x4 grow
x4
x4 grow
x4
x4 grow
x4
Gap

Mg+ uses a modular system to define the gap between elements with rem based unit (0 to 10rem) mg-gap[0-10] mg-row-gap[0-10] mg-row-gap[0-10]

x3
x3
x3
x3
x3
x3

Group

Groups are used to display a list of options to the user. Below, you will find examples of groups in their default state, as well as examples of how to trigger the group functionality.

  • France
  • Spain
  • Deuthshland
  • France
  • Spain
  • Deuthshland

Css helpers

CSS helpers are used to quickly apply styles to elements. Below, you will find examples of how to use CSS helpers to style various elements and components.

Positioning

Padding

.mg-pad[0-10] { padding: [0-10]rem; } .mg-pad-l[0-10] { padding-left: [0-10]rem; } .mg-pad-r[0-10] { padding-right: [0-10]rem; } .mg-pad-b[0-10] { padding-bottom: [0-10]rem; } .mg-pad-t[0-10] { padding-top: [0-10]rem; }

Marging

.mg-marg[0-10] { margin: [0-10]rem; } .mg-marg-l[0-10] { margin-left: [0-10]rem; } .mg-marg-r[0-10] { margin-right: [0-10]rem; } .mg-marg-b[0-10] { margin-bottom: [0-10]rem; } .mg-marg-t[0-10] { margin-top: [0-10]rem; } .mg-marg-auto { margin: auto; }

Placing

.mg-fit { min-width: 100%; } .mg-fixed-top { vertical-align: middle; } .mg-relative { position: relative; } .mg-fixed { position: fixed; } .mg-static { position: static; } .mg-sticky { position: sticky; } .mg-fixed-top { position: fixed; top: 0; left: 0; z-index: 999; } .mg-fixed-bottom { position: fixed; bottom: 0; left: 0; z-index: 999; } .mg-top { top: 0; } .mg-bottom { bottom: 0; } .mg-right { float: right; right: 0; } .mg-left { float: left; left: 0; } .mg-center { left: 50%; transform: translateX(-50%);} .mg-middle { top: 50%; transform: translateY(-50%); } .mg-top-left { top: 0; left:0; } .mg-top-right { top: 0; right:0; } .mg-bottom-left { bottom: 0; left:0; } .mg-bottom-right { bottom: 0; right:0; } .mg-text-center { text-align: center; } .mg-text-right { text-align: right; } .mg-text-left { text-align: left; }

Sizing

width and height

.mg-w[0-10] { width: [0-10]rem; } .mg-h[0-10] { height: [0-10]rem; } .mg-min-w[0-10] { min-witdh: [0-10]rem; } .mg-min-h[0-10] { min-height: [0-10]rem; } .mg-max-w[0-10] { max-width: [0-10]rem; } .mg-max-h[0-10] { max-height: [0-10]rem; }
0 to 100vh step 10 .mg-w[0-100]vh { width: [0-100]vh; } .mg-h[0-100]vh { height: [0-100]vh; } .mg-min-w[0-100]vh { min-witdh: [0-100]vh; } .mg-min-h[0-100]vh { min-height: [0-100]vh; } .mg-max-w[0-100]vh { max-width: [0-100]vh; } .mg-max-h[0-100]vh { max-height: [0-100]vh; }

Visibility

.mg-block { display: block; } .mg-inline-block { display: inline-block; } .mg-inline { display: inline; } .mg-none { display: none; } .mg-show { visibility: visible; opacity:1; } .mg-clearfix { transform: scale(1); } .mg-shadow { box-shadow: $control-shadow; } .mg-overflow-auto { overflow: auto; } .mg-overflow-x-auto { overflow-x: auto; } .mg-overflow-y-auto { overflow-y: auto; } .mg-overflow-x-hidden { overflow-x: hidden; } .mg-overflow-y-hidden { overflow-y: hidden; } .mg-visible { visibility: visible; } .mg-hidden { visibility: hidden;} .mg-rounded[0-10] { border-radius: [0-10]rem;} .mg-rounded-tl[0-10] { border-top-left-radius: [0-10]rem;} .mg-rounded-tr[0-10] { border-top-right-radius: [0-10]rem;} .mg-rounded-br[0-10] { border-bottom-right-radius: [0-10]rem;} .mg-rounded-bl[0-10] { border-bottom-left-radius: [0-10]rem;} .mg-rounded-none { border-radius: 0;} .mg-rounded-full { border-radius: 100%;}

z-index (0 to 500 step 100)

.mg-z[0-5] { z-index: [0-500];} .mg-z-full { z-index: 999;}

Text

.mg-text-left { text-align: left; } .mg-text-right { text-align: right; } .mg-text-center { text-align: center; } .mg-text-justify { text-align: justify; } .mg-text-nowrap { white-space: nowrap; } .mg-text-lowercase { text-transform: lowercase; } .mg-text-uppercase { text-transform: uppercase; } .mg-text-capitalize { text-transform: capitalize; } .mg-text-underline { text-decoration: underline; } .mg-text-linethrough { text-decoration: linethrough; } .mg-text-overline { text-decoration: overline; } .mg-text-none { text-decoration: none; } .mg-text-break { word-break: break-all; } .mg-text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} .mg-text-clip { overflow: hidden; text-overflow: clip; white-space: nowrap; } .mg-text-[s-m-l-xl-2xl-3xl-4xl-5xl] { font-size: $base-font-size*N; } .mg-text-bold { font-weight: bold; } .mg-text-bolder { font-weight: bolder; } .mg-text-lighter { font-weight: lighter; }

Icons

Included icons (pure css)

Navigation

The icons are categorized into different groups based on their usage. Below, you will find examples of navigation icons and action icons, all implemented using pure CSS.

Additionally, we demonstrate the different sizes available for these icons, ranging from small (s) to 5 extra-large (5xl). This ensures that the icons can be used in a variety of contexts and maintain visual consistency across the application.

Actions

The icons are categorized into different groups based on their usage. Below, you will find examples of navigation icons and action icons, all implemented using pure CSS.

Additionally, we demonstrate the different sizes available for these icons, ranging from small (s) to 5 extra-large (5xl). This ensures that the icons can be used in a variety of contexts and maintain visual consistency across the application.

Icon sizing (s to 5xl)

The icons are categorized into different groups based on their usage. Below, you will find examples of navigation icons and action icons, all implemented using pure CSS.

Additionally, we demonstrate the different sizes available for these icons, ranging from small (s) to 5 extra-large (5xl). This ensures that the icons can be used in a variety of contexts and maintain visual consistency across the application.

Sizing with external icons (svg)

Icon integration

Buttons

We provide examples of buttons with inline icons, as well as buttons that use SVG icons. These examples demonstrate how icons can be seamlessly integrated into button elements to enhance usability and visual appeal.

Badges

We provide examples of badges with inline icons, as well as badges that use SVG icons. These examples demonstrate how icons can be seamlessly integrated into badge elements to enhance usability and visual appeal.

filter warning

Inputs

Inputs are used to collect user information and submit it to the server. Below, you will find examples of inputs in their default state, as well as examples of how to trigger the input functionality.

Input sizing

Styled inputs

Loader

Loaders are used to indicate that a process is in progress. Below, you will find examples of how to use the loader system to create a variety of loading states.

Loader needs few js code to toggle state of loader
Loading...
Loaded

Progress

Progress bars are used to indicate the progress of a process. Below, you will find examples of how to use the progress system to create a variety of progress states.

Radio

Radio buttons are used to select a single option from a list of options. Below, you will find examples of radio buttons in their default state, as well as examples of how to trigger the radio button functionality.

Range

Range sliders are used to select a value from a range of values. Below, you will find examples of how to use the range system to create a variety of range states.

Responsive display

Responsive display classes allow you to show or hide elements based on the screen size. This is useful for creating a responsive layout that adapts to different screen sizes.

no JS required, following rules works only with CSS Resize your browser or switch to virutal mobile mode to check changes
Hidden effect (s,m,l,xl)
mg-s-hiddenhidden for small screen
mg-m-hiddenhidden until medium screen
mg-l-hiddenhidden until large screen
mg-xl-hiddenhidden until extra large screen
Display effect (s,m,l,xl)
mg-s-displaydisplay for small screen
mg-m-displaydisplay until medium screen
mg-l-displaydisplay until large screen
mg-xl-displaydisplay until extra large screen
Progressive display example
Exclusive display example

It shows only icon with current screen size

Select

Selects are used to select a single option from a list of options. Below, you will find examples of how to use the select system to create a variety of select states.

Tabs

Tabs are used to display a list of options to the user. Below, you will find examples of how to use the tabs system to create a variety of tab states.

Tabs needs js to toggle class visibility
1 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni iste, placeat voluptates sapiente blanditiis fuga ullam. Iure dolorum libero fugit quidem, voluptate veniam aut animi nihil voluptas mollitia, aliquid inventore.
2 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni iste, placeat voluptates sapiente blanditiis fuga ullam. Iure dolorum libero fugit quidem, voluptate veniam aut animi nihil voluptas mollitia, aliquid inventore.
3 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni iste, placeat voluptates sapiente blanditiis fuga ullam. Iure dolorum libero fugit quidem, voluptate veniam aut animi nihil voluptas mollitia, aliquid inventore.

Timeline

Timelines are used to display a list of events in chronological order. Below, you will find examples of how to use the timeline system to create a variety of timeline states.

vertical (default)

  • 2021
    Project inception and initial development phase.
  • 2022
    First release
  • 2023
    Enhancement
  • 2024
    Stable release

inline

  • 2021
    Project inception and initial development phase.
  • 2022
    First release
  • 2023
    Enhancement
  • 2024
    Stable release

Toggle

Toggles are used to switch between two states. Below, you will find examples of how to use the toggle system to create a variety of toggle states.