Giter Club home page Giter Club logo

sveltestrap's Introduction

sveltestrap

Bootstrap 5 components for Svelte v3

The philosophy of this library is to provide all Bootstrap 5 components for a Svelte app, without needing to use Bootstrap component classes or needing to include Bootstrap's JavaScript.

However, to make using Bootstrap themes easier, this library does not embed Bootstrap styles directly and you will need to include Bootstrap 5 CSS in your page.

Note: Bootstrap 4 CSS users must use Sveltestrap 4 - see docs here: Sveltestrap version 4

The component names and interface are inspired by the reactstrap library for React.

Demo page


Install

npm install svelte sveltestrap

Usage

You need to include a link to Bootstrap 5 stylesheet in your page - these components do not include or embed any Bootstrap styles automatically.

Either in your HTML layout:

<head>
  <link
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
  />
</head>

Or from your Svelte app, either:

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
</svelte:head>

or:

<style>
  @import "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css";
</style>

or alternately, use the Styles component:

<script>
  import { Styles } from 'sveltestrap';
</script>

<Styles />

Then use sveltestrap components in your svelte component:

<script>
  import { Button, Col, Row } from 'sveltestrap';
</script>

<Row>
  <Col>
    <Button color="primary" outline>Hello World!</Button>
  </Col>
</Row>

Note on Icons

If you wish to use the Icon component, you also must include a link to Bootstrap Icon CSS, for example:

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
</svelte:head>

or:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
/>

or the Styles component includes the Bootstrap Icon CSS by default:

<script>
import { Styles } from 'sveltestrap';
</script>
<Styles />

Note on usage with Sapper

If you are using Sveltestrap with Sapper, it's recommended you import the component source directly. Note that this issue does not affect SvelteKit. For example:

<script>
  import { Button, Col, Row } from 'sveltestrap/src';
</script>

<Row>
  <Col>
    <Button color="primary" outline>Hello World!</Button>
  </Col>
</Row>

if you prefer the 'sveltestrap' import, you can move the package to devDependencies block in your package.json so that sapper will parse the es bundle

"devDependencies": {
    "sveltestrap": "*.*.*",
    ...
  },

sveltestrap's People

Contributors

benmccann avatar bestguy avatar blackfenix2 avatar coyotte508 avatar daniacu avatar davidroeca avatar daytonlowell avatar dependabot[bot] avatar dym-sh avatar eddie0329 avatar frederikhors avatar gary-mycase avatar geoffreymugnier avatar gorbulasdev avatar javajudt avatar jlith avatar kaipaysen avatar ladeiko avatar lovasoa avatar masrlinu avatar mohe2015 avatar mopeneko avatar newbyca avatar ojford avatar ondrap avatar renerick avatar rornic avatar thebosz avatar thecodejack avatar ubersan avatar

Watchers

 avatar

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.