Giter VIP home page Giter VIP logo

tailwind-bootstrap-grid's Introduction

tailwind-bootstrap-grid

npm version Build Status License: MIT

Bootstrap v5 flexbox grid system as a Tailwind CSS plugin.

Check the demo.

Installation

npm i -D tailwind-bootstrap-grid

In tailwind.js file:

module.exports = {
  plugins: [
    require('tailwind-bootstrap-grid')({
      containerMaxWidths: {
        sm: '540px',
        md: '720px',
        lg: '960px',
        xl: '1140px',
      },
    }),
  ],
};

And don't forget to include components and utilities in your tailwind base css file:

@tailwind base;
@tailwind components;
@tailwind utilities;

This will generate Bootstrap v5 flexbox grid.

* NOTE: When using the .container class from this plugin you will need to disable the core container plugin as both plugins expose a .container class.

Features & Tailwind CSS options support

  • ✅ custom screens
  • ✅ custom separator
  • ✅ custom prefix
  • ✅ important
  • ✅ rtl support

Options

  • Original Bootstrap grid's options:

    • gridColumns (default - 12) - grid size
    • gridGutterWidth (default - "1.5rem") - container and rows gutter width
    • gridGutters (default - { 0: 0 }) - gutter variable class steps (--bs-gutter-x, --bs-gutter-y)
    • containerMaxWidths (default - {}) - the max-width container value for each breakpoint
  • Extra options:

    • generateContainer (default - true) - whether to generate .container and .container-fluid classes
    • rtl (default - false) - rtl support (.offset-x classes will start responding to [dir=ltr] / [dir=rtl])
    • respectImportant (default - true) - whether it should respect the important root config option

FAQ

  1. Why my .container doesn't have padding? This plugin will not work properly with core container plugin as both plugins expose a .container class.
  2. How to use rtl css? Set the ltr or rtl dir attribute on your container (usually the root html).
  3. Is there a Bootstrap v4 grid implementation? Yes, use tailwind-bootstrap-grid@3.

Related

postcss-bootstrap-4-grid

tailwind-bootstrap-grid's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar karolis-sh avatar mantasstikleris avatar mikouaji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tailwind-bootstrap-grid's Issues

RTL support

  • implement the feature as an option
  • RTL friendly docs to display this feature

Incorrect instructions

When updating the tailwind file, the current documentation says to add:

@tailwind preflight;

This throws an error @tailwind preflight is not a valid at-rule in Tailwind v1.0, use @tailwind base instead during build, and should be:

@tailwind base;

Can't @apply styles

Hi, is there a reason why I can't @apply the classes generated by this plugin?

.cool-class-which-is-also-a-col { @apply col-6 }

This will not throw an error but also not apply any styles to the class.

Support for responsive variants of containers

Great plugin! It would be cool if there was support for responsive variants of containers.

My use case is to be able to do something like this:

<!-- not a container on xs, container-fluid from md onwards, container from lg onwards -->
<div class="md:container-fluid lg:container">...</div>
<!-- or the opposite -->
<div class="md:container lg:container-fluid">...</div>

Demo 404

When clicking on the Demo link in the README it takes to a 404

Site Not Found

image

Gutters not working

Hey, I am trying to change the gutter with g-* class. but it's not generating any CSS at all. how to use it? (I am using the tailwind container, not this plugin container)

only g-0 works, but I want g-2/3/4/5

image

Not working with Latest Tailwind and Purge

Hi, I have installed Tailwind and this along with postcss all globally and properly configured it

But it doesn't generate a single class related to grids..

module.exports = { // mode: 'jit', corePlugins: { container: false, }, purge: { enabled: true, content: [ './index.php', './results.php', ], }, darkMode: false, // or 'media' or 'class' theme: { }, variants: { extend: {}, }, plugins: [ //require('@tailwindcss/forms')({ strategy: 'class', }) require('@tailwindcss/forms'), require('tailwind-bootstrap-grid'), ], }

generate responsive gutter widths

hi -- is there a way to generate responsive gutter widths ie:

gridGutterWidth (default - "30px") - { sm: '20px', lg: '40px' } 
containerMaxWidths (default - { sm: '540px', md: '720px', lg: '960px', xl: '1140px' }

(so gutters change dynamically between desktop/mobile)

thanks

Support for !important

When you set a custom gutter size the no gutter option no longer takes effect since it's set without a !importnat but the custom gutter size does have a !important
Screenshot from 2021-01-28 11-37-18

How to disable container core plugin?

I am getting the following error:

WARN ⚠️ The container core plugin is enabled and you're also generating .container class with the tailwind-bootstrap-grid plugin. This might lead to unexpected styling issues, disable either of one.

But how to disable the container core plugin? The readme links to a section of a page that does not exist: https://tailwindcss.com/docs/container#disabling-entirely

Maybe also update the readme for everyone to come :)

Disable container?

This is a great lib!!

The docs state the following:
* NOTE: When using the .container class from this plugin you will need to disable the core container plugin as both plugins expose a .container class.

I tried to find that for Tailwind 3 and saw [this] (https://redpixelthemes.com/blog/tailwindcss-container-component). It basically says that the container class will not be generated if it's not used. But when I use it via the tailwind-bootstrap-grid would the tailwind container be generated?
How shoudl we deal with this?

Container max-width customization

Add ability to customize max-width as per bootstrap docs:

$grid-columns:      12;
$grid-gutter-width: 30px;

$grid-breakpoints: (
  // Extra small screen / phone
  xs: 0,
  // Small screen / phone
  sm: 576px,
  // Medium screen / tablet
  md: 768px,
  // Large screen / desktop
  lg: 992px,
  // Extra large screen / wide desktop
  xl: 1200px
);

$container-max-widths: (
  sm: 540px,
  md: 720px,
  lg: 960px,
  xl: 1140px
);

Responsive container paddings and cancel container class

I made a preset that extends this plugin. Posting it here if anyone will need it.

If applied this preset will:

  • Include tailwind-bootstrap-grid with all the passed options
  • Make container paddings on different screen sizes based on gridGutters
  • Add 2 classes for cancelling the container paddings

tailwind/tailwind-bootstrap-grid-preset.js

const plugin = require('tailwindcss/plugin');
const tailwindBootstrapGrid = require('tailwind-bootstrap-grid');

/**
 * This plugin will extend `tailwind-bootstrap-grid` by adding
 * - specific container paddings based on screen size
 * - classes for canceling the container padding
 */
const tailwindBootstrapGridExtended = plugin.withOptions((options) => {
	return (pluginOptions) => {
		const { addComponents, config } = pluginOptions;
		const screens = config('theme.screens');
		const screenKeys = Object.keys(screens);
		const { gridGutterWidth = '1.5rem', gridGutters = {} } = options;

		addComponents({
			'.container-cancel': {
				'margin-inline': `calc(${gridGutterWidth} / 2 * -1)`,
			},
		});

		addComponents(
			screenKeys
				.filter((name) => gridGutters[name])
				.map((name) => ({
					[`@screen ${name}`]: {
						'.container': {
							'--bs-gutter-x': gridGutters[name],
						},
						'.container-cancel': {
							'margin-inline': `-${gridGutters[name]}`,
						},
					},
				})),
		);

		addComponents({
			'.container-cancel-none': {
				'margin-inline': 0,
			},
		});
	};
});

module.exports = (options) => ({
	plugins: [
		tailwindBootstrapGrid(options),
		tailwindBootstrapGridExtended(options),
	],
});

tailwind.config.js

const tailwindBootstrapGridPreset = require('./tailwind/tailwind-bootstrap-grid-preset');

/** @type {import('tailwindcss').Config} */
module.exports = {
	presets: [
		tailwindBootstrapGridPreset({
			gridGutterWidth: '1.5rem',
			gridGutters: {
				sm: '1rem',
				md: '1.5rem',
				lg: '2rem',
				xl: '2.5rem',
			},
			containerMaxWidths: {
				sm: 'none',
				md: 'none',
				lg: '1366px',
				xl: '1366px',
			},
		}),
	],
};

Please add way to configure margin-approach

Hi. I love bootstrap grid, but I like margin-top for elements instead of margin-bottom, how like bootstrap authors.
So, now If I have this type of code, I have wrong behaviour on interaction.

<div>
<button style="height: 20px">some clickable</button>
<div class="row gy-20">....</div>
</div>

Because row has negative margin and goes after button it content has a larger index and overlaps the button if it does not have a directly given index.
With margin-bottom on row I don't have this issue in most cases.
So, instead of copy-paste source code and to change only this styles, maybe you will introduce a param to use marginBottom instead for those who like me wants this?
Thanks.

Container margin not set

Hi, I just installed and included this library and I have an issue with the container class. "margin-left" and "margin-right" are not set and so my content sticks to the left of the screen.

I searched my code for other occurences of the container class but I have no definitions of it myself. In the webinspector I can see that the styles are not overriden but simply missing from the container class.

Do you have any idea what could cause this?

PS: I added my own definition of "container" and gave it the margin that way but this feels dirty...

Full custom prefix support

With following options:

  options: {
    prefix: '✅-',
    separator: '_🚧_',
  },

The following css gets generated:

.✅-row.✅-no-gutters {
  margin-right: 0;
  margin-left: 0;
}

.✅-row.✅-no-gutters > .✅-col,
.✅-row.✅-no-gutters > .✅-mobile_🚧_col,
.✅-row.✅-no-gutters > .✅-tablet_🚧_col,
.✅-row.✅-no-gutters > .✅-desktop_🚧_col,
.✅-row.✅-no-gutters > [class*="col-"],
.✅-row.✅-no-gutters > [class*="mobile_🚧_col-"],
.✅-row.✅-no-gutters > [class*="tablet_🚧_col-"],
.✅-row.✅-no-gutters > [class*="desktop_🚧_col-"] {
  padding-right: 0;
  padding-left: 0;
}

While this is the expected output

.✅-row.✅-no-gutters {
  margin-right: 0;
  margin-left: 0;
}

.✅-row.✅-no-gutters > .✅-col,
.✅-row.✅-no-gutters > .mobile_🚧_-col,
.✅-row.✅-no-gutters > .tablet_🚧_-col,
.✅-row.✅-no-gutters > .desktop_🚧_-col,
.✅-row.✅-no-gutters > [class*="✅-col-"],
.✅-row.✅-no-gutters > [class*="mobile_🚧_✅-col-"],
.✅-row.✅-no-gutters > [class*="tablet_🚧_✅-col-"],
.✅-row.✅-no-gutters > [class*="desktop_🚧_✅-col-"] {
  padding-right: 0;
  padding-left: 0;
}

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.35.3 to 4.36.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v4.36.0

Features

  • SourceMapDevToolPlugin append option now supports the default placeholders in addition to [url]
  • Arrays in resolve and parser options (Rule and Loader API) support backreferences with "..." when overriding options.
Commits

The new version differs by 42 commits.

  • 95d21bb 4.36.0
  • aa1216c Merge pull request #9422 from webpack/feature/dot-dot-dot-merge
  • b3ec775 improve merging of resolve and parsing options
  • 53a5ae2 Merge pull request #9419 from vankop/remove-valid-jsdoc-rule
  • ab75240 Merge pull request #9413 from webpack/dependabot/npm_and_yarn/ajv-6.10.2
  • 0bdabf4 Merge pull request #9418 from webpack/dependabot/npm_and_yarn/eslint-plugin-jsdoc-15.5.2
  • f207cdc remove valid jsdoc rule in favour of eslint-plugin-jsdoc
  • 31333a6 chore(deps-dev): bump eslint-plugin-jsdoc from 15.3.9 to 15.5.2
  • 036adf0 Merge pull request #9417 from webpack/dependabot/npm_and_yarn/eslint-plugin-jest-22.8.0
  • 37d4480 Merge pull request #9411 from webpack/dependabot/npm_and_yarn/simple-git-1.121.0
  • ce2a183 chore(deps-dev): bump eslint-plugin-jest from 22.7.2 to 22.8.0
  • 0beeb7e Merge pull request #9391 from vankop/create-hash-typescript
  • bf1a24a #9391 resolve super call discussion
  • bd7d95b #9391 resolve discussions, AbstractMethodError
  • 4190638 chore(deps): bump ajv from 6.10.1 to 6.10.2

There are 42 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.