Skip to content

Getting started

Welcome to Shadcn UI for Flutter. This is the official documentation for Shadcn UI for Flutter.

Shadcn UI

The work is still in progress.

Installation

Run this command in your terminal from your project root directory:

Terminal window
flutter pub add shadcn_ui

or manually adding to your pubspec.yaml:

dependencies:
shadcn_ui: ^0.2.4 # replace with the latest version

Shadcn (pure)

Use the ShadApp widget if you want to use just the ShadcnUI components, without Material or Cupertino.

import 'package:shadcn_ui/shadcn_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
}

Shadcn + Material

We are the first Flutter UI library to allow shadcn components to be used simultaneously with Material components. The setup is simple:

import 'package:shadcn_ui/shadcn_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
return ShadApp.material();
}

The ShadApp widget automatically creates a Material ThemeData. If you need to customize the Material theme use materialThemeBuilder:

import 'package:shadcn_ui/shadcn_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp.material(
materialThemeBuilder: (context, theme) {
return theme.copyWith(
appBarTheme: const AppBarTheme(toolbarHeight: 52),
);
},
);
}

Shadcn + Cupertino

If you need to use shadcn components with Cupertino components, use ShadApp.cupertino.

import 'package:shadcn_ui/shadcn_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
return ShadApp.cupertino();
}

The ShadApp widget automatically creates a CupertinoThemeData and a Material ThemeData. If you need to customize the Material theme use materialThemeBuilder, and cupertinoThemeBuilder to customize the Cupertino theme:

import 'package:shadcn_ui/shadcn_ui.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp.cupertino(
cupertinoThemeBuilder: (context, theme) {
return theme.copyWith(applyThemeToAll: true);
},
materialThemeBuilder: (context, theme) {
return theme.copyWith(
appBarTheme: const AppBarTheme(toolbarHeight: 52),
);
},
);
}

Shadcn + Custom App

If you want to integrate Shadcn with a custom WidgetsApp integration, like GetX (GetMaterialApp) you can use ShadApp.custom

import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
return ShadApp.custom(
appBuilder: (context, theme) => GetMaterialApp(
theme: theme,
builder: (context, child) {
return ShadToaster(child: child!);
},
),
);
}