Skip to content

MgPlus is a micro CSS library to build efficient web pages

License

Notifications You must be signed in to change notification settings

mgpluscss/mgplus

Repository files navigation

MgPlus (Mg+)

Mg+ micro CSS library

Build websites with just a few drops of css

Latest release on NPM

Striking the perfect balance between features and simplicity

Formerly called Milligram Plus, Mg+ was based on milligram and provides a minimal setup of styles for a fast and clean starting point without any dependencies

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

Only one css file, around 57 KB minified

Live integration

Demo page

Corporate website integration

Advantages

  • Lightweight and many components implemented
  • Reponsive and mobile first design
  • Sass sources could be extended or composed for your custom needs
  • Optional: use js plugins to interact with some component, it's straightforward: you don't have to run any custom js code in your website
  • Components are juste html markups, it could be integrated easily in any web framework like php, react, vue or angular

Features

  • Custom variables
  • Theming (dark mode)
  • Navs
  • Tabs
  • Pretty forms inputs
  • Badges
  • Modals
  • Responsive grid system
  • Icon helper including some css icons
  • Styling helpers like tailwindcss for positionning and sizing

Getting started

Quick start

Import mgplus.css to your website from our CDN

 <link rel="stylesheet" type="text/css" href="https://cdn.mgpluscss.com/v1.2.9/css/mgplus.css" />

Import mgplus-dom.js to your website from our CDN and register required components as query params

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

Import mgplus from NPM

Install dependencies from npm

npm

npm install mgplus

yarn

yarn add mgplus

pnpm

pnpm install mgplus

Finaly import mgplus.css from your node_modules folder

Use JS plugins without additional coding

mgplus-dom.js plugin allows to handle UI interaction for some components (toggle classes on dom events) They are mainly used to toggle visibility of content inside a component

To register automatically all or specific plugins on page load, use "register_plugins" query param when you import mgplus-dom.js

Example

Register all plugins
<script src="https://cdn.mgpluscss.com/v1.2.9/js/mgplus-dom.js?
register_plugins=dropdowns,tabs,modals,collapses,darkmode" ></script>
Register only darkmode
<script src="https://cdn.mgpluscss.com/v1.2.9/js/mgplus-dom.js?
register_plugins=darkmode" ></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-dropdown--icon" 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>

To configure darkmode plugin

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

<!DOCTYPE html>
<html lang="en" data-theme="auto">

<head>
</head>

"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

Debugging

Debugging demo page locally

  • Clone the repository
git clone https://github.com/Evodim/mgplus.git

Install packages

npm install

Start demo page

npm run start

Debugging with auto reload

Run watch command to enable hot reload for the scss library

npm run watch

In order to start watch command, you should launch demo page with start command in another process

Build only the library

npm run build

yarn, pnpm commands are also supported

License

Licensed under the MIT License.

This library is in active development, some breaking may occurs until next major release including a new documentation portal.

A complete documentation page will be available soon