Files
tabler/docs/content/ui/getting-started/installation.mdx
T

94 lines
3.6 KiB
Plaintext

---
title: Installation
order: 1
summary: Set up Tabler in a plain HTML file. Create the page, add the CSS and JavaScript from the CDN, and open it in the browser.
description: 'Set up Tabler in a plain HTML file with the CSS and JavaScript from the CDN.'
---
import Example from '@components/Example.astro'
import CdnImportPackage from '@components/CdnImportPackage.astro'
import { Code } from 'astro:components'
import { cdnCssTag, cdnJsTag } from '@lib/cdn-snippets.ts'
import Steps from '@components/Steps.astro'
Using a framework? See [Tabler framework integration guides](/ui/getting-started/frameworks).
This page walks through the shortest way to get Tabler running: one HTML file, two tags from the CDN, and a page you can open in the browser. There's no build step involved.
## Setup
<Steps>
### Create a basic HTML file
Start with a new `index.html` file in the root of your project. It only needs the usual HTML skeleton and a `<meta name="viewport" />` tag, so the page scales correctly on phones:
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tabler demo</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
```
### Add Tabler CSS and JavaScript
Next, add Tabler's CSS and JavaScript. These two tags load the core files from the CDN:
<CdnImportPackage />
Put the stylesheet in `<head>` and the script at the end of `<body>`. The file then looks like this:
<Code
lang="html"
code={`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tabler Demo</title>
${cdnCssTag()}
</head>
<body>
<h1>Hello, Tabler!</h1>
${cdnJsTag()}
</body>
</html>`}
/>
That's the whole setup. The CSS covers the layout and components, and the script adds the interactive parts such as dropdowns and modals.
The `integrity` attribute lets the browser check that the file it downloaded is the one Tabler published, and `crossorigin="anonymous"` is what makes that check possible on a CDN. Each hash belongs to one file of one version, so when you move to a newer Tabler, copy the tags from this page again instead of only changing the version number in the URL.
If you'd rather not depend on a CDN, you can download the files and serve them from your own project. The [Download](/ui/getting-started/download) page explains how.
### Open in your browser
Save the file and open it in your browser. You should see your first page styled by Tabler. From here you can add a layout, drop in components and build up the app.
</Steps>
## Bootstrap is already included
Tabler's JavaScript file contains Bootstrap's JavaScript. Do not load `bootstrap.bundle.js` or `import 'bootstrap'` next to it.
<Warning title="Load Bootstrap only once">
With two copies on the page, every `data-bs-toggle` element gets two handlers. One click then opens two backdrops for a modal or an offcanvas, and dropdowns and tooltips open twice.
</Warning>
Use the components that Tabler exposes instead. With the script tag they are on the `tabler` global, for example `tabler.Modal` or `tabler.Offcanvas`. With a bundler, import them from the package:
```js
import { Modal, Offcanvas } from '@tabler/core'
```
If you need your own copy of Bootstrap's JavaScript, load only Tabler's CSS and leave `tabler.js` out.
If you want to see what's possible, the demo pages at [preview.tabler.io](https://preview.tabler.io) show every layout and component in use. The rest of this documentation covers each of them in detail.