Socket
Socket
Sign inDemoInstall

@sveltestrap/sveltestrap

Package Overview
Dependencies
20
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @sveltestrap/sveltestrap

Bootstrap components for Svelte


Version published
Weekly downloads
4.6K
increased by5.7%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Unit Tests Integration Tests license npm version

Bootstrap 5 Components for Svelte 4+

Sveltestrap is a library designed to simplify the integration of Bootstrap 5 components into your Svelte applications. It eliminates the need for Bootstrap component classes, the inclusion of Bootstrap's JavaScript, and reliance on jQuery.

This open-source software is freely available under the permissive MIT license. It draws inspiration from the reactstrap library for React.

Please note that Sveltestrap does not directly embed Bootstrap style. To use Bootstrap themes effectively, you must include Bootstrap 5 CSS using one of the methods outlined below.

Note If you looking for Svelte 3.x support, you can use the original sveltestrap package.

Join the Community

Discord


Install

# npm
> npm install svelte @sveltestrap/sveltestrap

# pnpm
> pnpm install svelte @sveltestrap/sveltestrap

# yarn
> yarn add svelte @sveltestrap/sveltestrap

Bootstrap CSS

It's essential to note that Bootstrap 5 components do not come with Bootstrap styles preloaded, so you'll need to add the stylesheet manually. Here's how you can add them:

  1. Add to your apps static index.html file
<head>
  <link
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
  />
</head>
  1. Add to your main App.svelte file
<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
</svelte:head>
  1. Import the styles directly in your CSS bundle
<style>
  @import 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css';
</style>
  1. Use the provided Styles component
<script>
  import { Styles } from '@sveltestrap/sveltestrap';
</script>

<Styles />

Then use Sveltestrap components in your svelte component:

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

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

Bootstrap Icons

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

Include it in your app's App.svelte:

<svelte:head>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
</svelte:head>

or you can include it in your app's index.html:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"
/>

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

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

<Styles />

Using 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.

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

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

If you prefer the @sveltestrap/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": "*.*.*",
  ...
},

Sponsors

avatar

Maintainers

avatar avatar

Contributors

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

Keywords

FAQs

Last updated on 16 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc