Skip to content
Playground

Flowbite

Installation

Terminal window
npm i @sjsf/form @sjsf/flowbite-theme

Install Flowbite Svelte

Quickstart - Flowbite Svelte

Setup styles

There is two ways to setup styles:

  1. Tailwind configuration
import flowbite from 'flowbite/plugin';
import { THEME_CONTENT, FLOWBITE_CONTENT } from '@sjsf/flowbite-theme/preset'
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{html,js,svelte,ts}', THEME_CONTENT, FLOWBITE_CONTENT],
plugins: [flowbite],
}
  1. Inject prepared styles (not recommended)
// Inject them as you like
import flowbiteStyles from "@sjsf/flowbite-theme/styles.css?inline";

Additional widgets

  • toggle

Demo

<script lang="ts">
import { theme } from "@sjsf/flowbite-theme";
import { astroTheme } from "@/theme.svelte";
import CustomForm from "@/components/custom-form.svelte";
import { schema, uiSchema } from "./_demo-schema";
const astro = astroTheme();
let value = $state();
</script>
<CustomForm
{...theme}
bind:value
{schema}
{uiSchema}
novalidate
onSubmit={console.log}
class="flex flex-col gap-4 mb-4 {astro.darkOrLight}"
/>
<pre>{JSON.stringify(value, null, 2)}</pre>