You need to have an existing Angular project.
Install the main package and necessary peer dependencies:
npm i @piying-lib/angular-daisyuiIf the following peer dependencies are not already installed, run the corresponding commands:
npm i @piying/view-angular@^2.7.1
npm i daisyui@^5.5.19
npm i @angular/cdk@>=20.0.0
npm i @angular/material@>=20.0.0
npm i @cyia/ngx-common@>=20.0.4If Tailwind CSS is not already installed in your project, follow the Tailwind CSS Angular guide.
Run the following command:
npm install tailwindcss @tailwindcss/postcss postcss --forceEdit the .postcssrc.json file:
{
"plugins": {
"@tailwindcss/postcss": {}
}
}If DaisyUI is not already installed in your project, follow the DaisyUI installation guide.
Run the following command:
npm i -D daisyui@latestAdd the following configuration to your main CSS file (e.g., src/styles.css or src/styles.scss):
@import 'tailwindcss';
@plugin "daisyui" {
themes:
light --default,
dark --prefersdark;
}
@source '../node_modules/@piying-lib/angular-daisyui/fesm2022';
@source '../node_modules/@piying-lib/angular-daisyui/preset-css/ts';Add the following to src/app/app.config.ts:
import {
ApplicationConfig,
provideBrowserGlobalErrorListeners,
provideZonelessChangeDetection,
} from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
+ import { ThemeService } from '@piying-lib/angular-daisyui/service';
import { provideHttpClient, withFetch } from '@angular/common/http';
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideZonelessChangeDetection(),
provideRouter(routes),
provideHttpClient(withFetch()),
+ ThemeService,
],
};Import all components from the preset (or manually configure to use specific components):
import { typedComponent } from '@piying/view-angular';
import { PresetDefine } from '@piying-lib/angular-daisyui/preset';
const safeDefine = typedComponent(PresetDefine);
export const FieldGlobalConfig = safeDefine.define;Directly resolve definitions through routing:
import { SchemaViewPage } from '@piying-lib/angular-core';
import * as v from 'valibot';
export const routes: Routes = [
{
path: 'hello',
component: SchemaViewPage,
data: {
// Valibot schema definition
schema: () => v.object({
l1: v.pipe(v.string()),
}),
// Configuration options
options: () => ({
fieldGlobalConfig: FieldGlobalConfig,
}),
// Model value
model: () => ({
l1: '12345',
}),
},
},
];