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.
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": "*.*.*",
...
},
Typescript types support?
I would like to use this lib in my svelte + typescript(preprocess) project, yet i'm having trouble importing it due to lack of types. Can someone provide @types/sveltestrap any soon? <3
test: improve alert
Changelog
@babel/plugin-transform-runtime
to be able to useasync
/await
@testing-library/jest-dom/extend-expect
to be able to use the expect extentionsqueryByRole
.error under "Svelte DevTools"
While trying 1st sample from https://bestguy.github.io/sveltestrap/?path=/story/components--navbar under "Svelte DevTools" (https://chrome.google.com/webstore/detail/svelte-devtools/ckolcbmkjpjmangdbmnkpjigpkddpogn?hl=en-US) I get the error below on console.
WIP: Typescript support
i made a PR to enable typescript support writing the .svelte files and copied the type definitions straight from ReactStrap.
This isn't a complete repo, i just needed an area to converse about adding type definitions.
Dependency error with SvelteKit v1.0.0-next.137
Getting this error twice when I run the dev server
npm run dev -- --host --open
...I am not referencing InlineContainer.svelte in any of my code but I am using Modal and Offcanvas which both reference it.
Using [email protected], SvelteKit 1.0.0-next.137, Svelte 3.40.2, vite 2.4.3, node 16.5.0
Got the same error creating a pristine project putting Offcanvas in the boilerplate index.svelte...
cd my-app
npm install --saveDev sveltestrap
Added this to the section tag...
Unused export properties...
Some of them...
Hello, It looks like since the latest update the
<ToolTip/>
element is broken and throwsHTMLElement is not defined
when server-side rendered.Initially reported in https://github.com/lovasoa/sanipasse/issues/145
Empty IDs invalidate HTML markup
Sveltestrap components like Container, Row etc. generate an empty
id=""
attribute on DOM nodes which is invalid according to the W3C spec. It would be great if this empty attribute could just be omitted if it's not set.Custom Modal transitions
What do you think about this?
I'm using it like below:
It works good!
Page JS weight
Svelte newby here, so please forgive me if this seems like a silly question. Isn't Svelte supposed to reduce the overall page weight? I'm seeing the sveltestrap page JS weight is many times the size of jQuery/Bootstrap 4 version. What am I missing?
Support SSR
I have created a simple Svelte starter for Meteor, and it was reported that
sveltestrap
doesn't work with my SSR solution. I believe this is because your component is published in a pre-compiled state, instead of providing raw source and exposing that through asvelte
key inpackage.json
as is demonstrated in sveltejs/component-template.Svelte's SSR support works by using an entirely different compiler for server rendering, and would seem to require raw source in order to function properly.
Disable transition (on Accordion)
It seems to me that it is currently impossible to easily disable transition of Sveltestrap components? I have two pages with the same
<Accordion stayOpen>
. When a user switches between those pages the Accordion slides open each time (you can also see this when switching back and forth to the Accordion component page). This can be distracting. Maybe I overlooked an easy way to disable these transitions? Or is there a more complex/hacky way to disable it?A11y: Modal and Offcanvas don't get keyboard focus
When you open a Sveltestrap Modal or Offcanvas with your keyboard, the focus stays on the background instead of moving to the Modal/Offcanvas (so you can interact with any forms/buttons there). This makes navigating using a keyboard really hard/impossible.
The Bootstrap Modal and Offcanvas do get keyboard focus when I try them out on the Bootstrap website.
Tested on Firefox 108.0.1 and Chromium 108.0.5359.124.
How do justify tab pane in sveltestrap
So I have tabs with three element
The problem is it defaults the tab alignment to left, how do I set it to justify, I tried adding nav-justified class in TabPane but it doesn't work
<TabPane class="nav-justified" tabId="alpha" tab="Proses" active>
Last resort would be to have native html tag with bootstrap class to do it, but I was wondering if it was possible with sveltestrap
Navigation CSS
I am using the standard navigation code. I have the hover-underline-animation and it works but there is a built in 8px padding that I am unable to override. Any suggestions on any way to have the animation work properly?
<div class="hover-underline-animation"> <Dropdown nav inNavbar> <DropdownToggle nav caret>Options </DropdownToggle> <DropdownMenu end> <DropdownItem>Option 1</DropdownItem> <DropdownItem>Option 2</DropdownItem> <DropdownItem divider /> <DropdownItem>Reset</DropdownItem> </DropdownMenu> </Dropdown> </div>
Property not updating as expected in Modal
I am a React user, and am having trouble understanding how and when values get updated in svelte. I'm just trying to pass a value into a component updated via a user action. Here are the basics of my code:
So, what am I doing wrong here? The
currentPollType
prop is alwaysnull
in the child component. If I put<PollResponses>
outside the Modal, it updates as expected.StackOverflow issue: https://stackoverflow.com/q/74868657/173630
Bump decode-uri-component from 0.2.0 to 0.2.2
Bumps decode-uri-component from 0.2.0 to 0.2.2.
Release notes
Sourced from decode-uri-component's releases.
Commits
a0eea46
0.2.2980e0bf
Prevent overwriting previously decoded tokens3c8a373
0.2.176abc93
Switch to GitHub workflows746ca5d
Fix issue where decode throws - fixes #6486d7e2
Update license (#1)a650457
Tidelift tasks66e1c28
Meta tweaksDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)@dependabot use these labels
will set the current labels as the default for future PRs for this repo and language@dependabot use these reviewers
will set the current reviewers as the default for future PRs for this repo and language@dependabot use these assignees
will set the current assignees as the default for future PRs for this repo and language@dependabot use this milestone
will set the current milestone as the default for future PRs for this repo and languageYou can disable automated security fix PRs for this repo from the Security Alerts page.