Skip to content
Playground

DaisyUI

Installation

Terminal window
npm i @sjsf/daisyui-theme

Install daisyUI

Install daisyUI as a Tailwind CSS plugin

Setup styles

There is two ways to setup styles:

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

Additional widgets

  • toggle

Demo

<script lang="ts">
import { SimpleForm } from "@sjsf/form";
import { theme } from "@sjsf/daisyui-theme";
import { useAstro } from "@/astro.svelte";
import { useCustomForm } from "@/components/custom-form";
import { schema, uiSchema } from "./_demo-schema";
const astro = useAstro();
const form = useCustomForm({
...theme,
schema,
uiSchema,
});
</script>
<SimpleForm
{form}
novalidate
style="display: flex; flex-direction: column; gap: 1rem; background-color: transparent; margin-bottom: 1rem;"
data-theme={astro.darkOrLight}
/>
<pre>{JSON.stringify(form.value, null, 2)}</pre>