tb-grid is a super simple and lightweight 12 column responsive grid system utilizing css grid.

Overview

tb-grid

Lightweight (<1kb gzipped) 12 column grid system, built with css grid.

tb-grid-2

๐Ÿ‘‰ Demos & Playground

Have a look at those examples:

Simply fork the demos if you want to play around with tb-grid.

๐Ÿค” Why tb-grid?

Bootstrap's grid system is awesome. With very little code you can add responsiveness to your html in a declarative manner. The use of 12 columns make the grid system extremely versatile since you can divide it into nice fractions (12/2, 12/3, 12/4, 12/6 - they all produce integers!).

However, there are also some things bootstrap didn't get right.

  1. It requires too much nesting: .container > .row > .col. It would be great if we could drop the .container.
  2. Being able to change gutters (aka. gaps) on a case-by-case basis is important, but it's a bit cumbersome in bootstrap.
  3. The classes aren't scoped or namespaced. Furthermore .container and .row aren't that exotic that there would be no accidental collisions.
  4. While at 50kb minified the grid system isn't huge, it's not exactly tiny either.

tb-grid addresses all those gripes with bootstrap and frankly with all other grid systems we know (foundation, skeleton, ...).

๐Ÿคฏ What is tb-grid?

tb-grid is a reverse engineered bootstrap 12 column grid built with CSS grid. CSS grid allows us to build a solution in around 50 lines of scss, which translates into less than 500 lines of css (~1kb gzipped). It also allows us to drop one level of nesting that was required in bootstrap, since css grid supports gutters out of the box. Finally we made sure that everything lives under the tb-grid- prefix, so you'd have to be really unlucky for someone to accidentally use a class declared by this library.

๐Ÿš€ How can I install tb-grid?

There are a couple of ways how you can get tb-grid, choose what suits you best.

Option 1: SCSS

Copy the code from tb-grid.scss to your project.

Option 2: CSS

Copy the code from tb-grid.css to your project.

Option 3: npm

npm install tb-grid and include the scss or css file from there. (node_modules/tb-grid/tb-grid.scss or node_modules/tb-grid/tb-grid.css)

Option 4: npm CDN (unpkg)

You could use unkpg to get the file: <link rel="stylesheet" href="https://unpkg.com/[email protected]/tb-grid.css">

๐ŸŽจ How can I use tb-grid?

It is pretty similar to bootstrap, with the exception that it's simpler yet with better scoping:

  • Add the class .tb-grid to an HTML element.
  • Add classes of the form .tb-grid-<breakpoint>-<cols>, like .tb-grid-sm-6 or .tb-grid-md-8 to the direct children. The breakpoints are the same ones as in bootstrap (sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px). The column argument can be between 1 and 12.
  • Add .tb-grid-gap-<gap size> to define the gap size. Here, <gap-size> can be a value between (and including) 1 and 50.

Complete example:

<div class="tb-grid tb-grid-gap-10">
  <div class="tb-grid-sm-6">
    Item 1
  </div>
  <div class="tb-grid-sm-6">
    Item 2
  </div>
  <div class="tb-grid-sm-4 tb-grid-lg-6">
    Item 3
  </div>
  <div class="tb-grid-sm-8 tb-grid-lg-6">
    Item 4
  </div>
</div>

No tb-grid-gap-<px> value means no gaps / gutters, since that's the only default that is not arbitrary, and it's really easy to add a gap. We currently only support symmetrical gaps up to 50px to keep the bundle size small, but you can easily add your own classes to extend the functionality. For example .custom-gap {row-gap: 60px; column-gap: min(20px, 8%)}.

Note: When the tb-grid parent is smaller than column-gap * 12, the column-gap will be squished together to prevent overflows. For example, a column-gap of 30px becomes problematic when the tb-grid parent is 360px. That's why the tb-grid-gap-<px> classes use column-gap: min(<px>, 8%), to squish the column gutters when it gets too tight.

โœ‹ What limitations does tb-grid have?

  • It doesn't support old browsers (IE): https://caniuse.com/?search=grid . 95% of people are using browsers that support CSS grid as of April 2021. It's up to you to decide whether this is sufficient for your project.

๐Ÿคจ Do you really need tb-grid?

It is also fair to ask yourself whether you even want a 12 column grid system after all. It is really simple to add the grid on a per occasion basis, something like this:

.dashboard {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr;
  @media(min-width: $my-breakpoint-sm) {
    grid-template-columns: 1fr 1fr;
  }
}

You can easily use low level css to achieve the same thing and avoid introducing too much clutter into the html. Over the years the actual CSS grid API might also be more well known amongst devs than the "bootstrap API", which tb-grid builds upon. It even solves the problem of the squished gutters and might be computationally more efficient, even though I haven't tested if there's any actual difference.

You can even achieve a cool responsive experience without media queries:

.car-grid {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

Demo: https://jsfiddle.net/bersling/d3hjs5zv/3/

However, to achieve a consistent layout across a page, the 12 column grid system is a really easy-to-use and powerful tool. We've found it especially helpful on things like landing pages, where you often have different sections, jumbos etc. that should be aligned with one another but still responsive. So in our opinion, yes, tb-grid does make your life easier ๐Ÿ™‚

๐Ÿ’ฏ What's the status of the project?

  • The project is to be considered experimental and non-battle tested at this point
  • The API (class names) is not to be considered stable. Rather it is a working draft, and we'd love to receive feedback on it. This is also reflected in the npm version below 1.0.0.
  • Initial prototype is working well, see demos / playground above.
  • We would be thrilled to hear your opinions & suggestions on tb-grid! Why don't you just give it a spin and let us know what you think? You can just open an issue or drop us an email at daniel @ taskbase . com
You might also like...

Freewall is a cross-browser and responsive jQuery plugin to help you create grid, image and masonry layouts for desktop, mobile, and tablet...

Freewall is a cross-browser and responsive jQuery plugin to help you create grid, image and masonry layouts  for desktop, mobile, and tablet...

Freewall Freewall is a cross-browser and responsive jQuery plugin to help you create many types of grid layouts: flexible layouts, images layouts, nes

Dec 27, 2022

๐ŸŒ— 1 line of code to apply auto dark / light theme and support custom theme for your website. Super fast and lightweight theme library.

themes.js A super lightweight and fast Theme library with auto system color scheme detection in JavaScript. Features Auto detect Dark / Light mode by

Nov 29, 2022

โœ๏ธ Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped

โœ๏ธ Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped

Sugar High Introduction Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped Usage npm install --save sugar-high import { h

Dec 8, 2022

A super-lightweight, highly configurable, cross-browser date / time picker jQuery plugin

A super-lightweight, highly configurable, cross-browser date / time picker jQuery plugin

Zebra Datepicker A super-lightweight, highly configurable, cross-browser date/time picker jQuery plugin Zebra_Datepicker is a small yet and highly con

Dec 29, 2022

Responsive Tabs is a jQuery plugin that provides responsive tab functionality.

Responsive Tabs is a jQuery plugin that provides responsive tab functionality. The tabs transform to an accordion when it reaches a CSS breakpoint. You can use this plugin as a solution for displaying tabs elegantly on desktop, tablet and mobile.

Dec 8, 2022

This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X and O on a 3x3 grid.

This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X and O on a 3x3 grid.

Tic Tac Toe Game This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X a

Mar 4, 2023

The Main Purpose The main purpose of creating an anaonline information system, as an effort responsive to the management of the data of the Members of the Persis Youth based on information technology systems

landing-page-pp landing-page-pp.vercel.app #The Main Purpose The main purpose of creating an anaonline information system, as an effort responsive to

Oct 21, 2022

Lightweight and independent Pinterest-like cascading grid layout library

Lightweight and independent Pinterest-like cascading grid layout library

Bricklayer is a Lightweight and Independent Pinterest-like Cascading Grid Layout Library ๐Ÿ’Ž Simpler than any other cascading grid layout tools. โ„๏ธ Lig

Dec 22, 2022
Owner
Taskbase
Taskbase
Deno's first lightweight, secure distributed lock manager utilizing the Redlock algorithm

Deno-Redlock Description This is an implementation of the Redlock algorithm in Deno. It is a secure, lightweight solution to control resource access i

OSLabs Beta 223 Dec 31, 2022
:iphone: A super lightweight HTML, Sass, CSS, and JavaScript framework for building responsive websites

Responsive Boilerplate A powerful, accessible, developer friendly, framework for building responsive websites Responsive Boilerplate is the developers

ResponsiveBP 845 Dec 22, 2022
The Frontend of Escobar's Inventory Management System, Employee Management System, Ordering System, and Income & Expense System

Usage Create an App # with npx $ npx create-nextron-app my-app --example with-javascript # with yarn $ yarn create nextron-app my-app --example with-

Viver Bungag 4 Jan 2, 2023
Simple, responsive and lightweight Masonry Grid jQuery Plugin.

jquery-masonry-grid Simple, responsive and lightweight Masonry Grid jQuery Plugin. Installation Add the script before closing the <body> tag (make sur

Peter Breitzler 8 Jun 9, 2022
Import flow for Excel (.xlsx) and CSV file with automated column matching and validation.

RSI react-spreadsheet-import โšก๏ธ A component used for importing XLS / XLSX / CSV documents built with Chakra UI. Import flow combines: ?? Uploader โš™๏ธ P

Ugnis 123 Dec 24, 2022
A table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, row context menus, dark theme, and more.

Mantine DataTable A "dark-theme aware" table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagina

Ionut-Cristian Florescu 331 Jan 4, 2023
A community-led token scanner for Replit utilizing its own APIs.

Replit Token Scanner A community-led project that aims to scan published Repls to find secrets and invalidate them. Usage This repo contains the scann

Ray 18 Nov 6, 2022
The first ever MC:BE ForceOP Exploit utilizing a user impersonation exploit within Bedrock Dedicated Server

EliteElixir The first ever MC:BE ForceOP Exploit utilizing a user impersonation exploit within Bedrock Dedicated Server This tool uses the sub_client_

null 28 Jul 27, 2023
An npm package with Tailwind CSS utility classes for creating responsive grid columns without media queries using auto fit.

Grid Auto Fit for Tailwind CSS A plugin that helps you create a responsive grid layout in Tailwind CSS without using media queries. It uses the auto-f

Thirus 80 Dec 28, 2022
A super simple and lightweight API to get crypto token live information.

TokenStats ?? ?? A super simple and lightweight API to get crypto token live information. APP URL https://tokenstats.herokuapp.com/ Quick Start To get

Abdulfatai Suleiman 21 Jun 28, 2022