# @twbs-css/template-literals

> Bootstrap CSS as template & tagged literals

Latest version **2.0.1** (published 2023-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @twbs-css/template-literals
pnpm add @twbs-css/template-literals
yarn add @twbs-css/template-literals
bun add @twbs-css/template-literals
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2023-06-23 |
| First published | 2022-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 640.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nikolas Christou |
| Maintainers | nik.christou |
| Keywords | bootstrap css, bootstrap css components, template literals, lit tagged templates |

## Links

- npm: https://www.npmjs.com/package/@twbs-css/template-literals
- Repository: https://github.com/nik-christou/twbs-css.git#master
- Homepage: https://github.com/nik-christou/twbs-css/tree/master/packages/template-literals
- Issues: https://github.com/nik-christou/twbs-css/issues
- npm.io page: https://npm.io/package/@twbs-css/template-literals

## Dependencies (1)

- [lit](https://npm.io/package/lit.md) 2.7.5

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2023-06-23
- 2.0.0 — 2023-06-11
- 1.0.4 — 2023-06-11
- 1.0.3 — 2023-01-29
- 1.0.2 — 2022-12-23
- 1.0.1 — 2022-12-22
- 1.0.0 — 2022-12-22

## README

# template-literals
The purpose of this node library is to provide an easy and maintainable way to use existing 
bootstrap customization tools and generate css exported as string and tagged literals that
can easily be integrated into web components.

## Versioning
| Bootstrap 	 | Library versions 	 |
|-------------|--------------------|
| v5.2.x    	 | v1.0.x           	 |
| v5.3.x    	 | v2.0.x           	 |

## Installation

Install via npm:
```shell
npm install @twbs-css/template-literals
```

## Import

Example of importing bootstrap root css as template literal:
```javascript
import {HostCssTemplateLiteral} from '@twbs-css/template-literals';
```

Example of importing bootstrap root css as Lit tagged template literal:
```javascript
import {HostCssTaggedTemplate} from '@twbs-css/template-literals';
```

## Use case
Main use case is to allow easier css for web components (with string literals)
and for Lit elements components (with tagged templates).

Example using the string literals in plain web components:
```javascript
const template = document.createElement('template');
template.innerHTML = `
<style>
    ${HostCssTemplateLiteral}
</style>
<<add rest of html template>>`;
```

Example using the tagged template literals in Lit element components:
```javascript
static get styles() {
    return [
        HostCssTaggedTemplate
    ];
}
```

## Bootstrap CSS Layout template literal
The files `grid.literal.css.js` and its tagged version `grid.tagged.css.js` are using the default and well-known bootstrap grid system with the default settings.
However, since bootstrap v5.1.0 it provides an experimental grid system which is based on [CSS grid specification](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout) instead.
To use this grid system instead of the default one you can use files `grid-layout.literal.css.js` or its tagged `grid-layout.tagged.css.js`


## Generate bootstrap template literals with different sass variables
After cloning this branch you can:
- Add your variables to one of the existing `scss` files under `src/scss` or
- Add a new `scss` file under `src/scss` and your logic
  - Edit `bootstrap-items.js` to add the details so that the generator will know where to pick up the new file

After you are done with the changes, execute `npm run build` and the generated files are under `/dist`.

## Notes:
- Bootstrap `root` css will not work in case of web components since `:root` is only applicable to document. 
- You can use the `HostCssTemplateLiteral` or `HostCssTaggedTemplate` which is the same as root but will work for web components under shadow dom.
- `Type` css does not include the entire `reboot` css so in case you use both `reboot` and `type` just make sure `type` is the last item, so it can override rules.
- `Reboot` css includes both `:root` as well as `:host` media query for `prefers-reduced-motion`

---
_Source: https://npm.io/package/@twbs-css/template-literals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
