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';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
return ShadApp.custom(
themeMode: ThemeMode.dark,
darkTheme: ShadThemeData(
brightness: Brightness.dark,
colorScheme: const ShadSlateColorScheme.dark(),
),
appBuilder: (context) {
return MaterialApp(
theme: Theme.of(context),
builder: (context, child) {
return ShadAppBuilder(child: child!);
},
);
},
);
}

The default Material ThemeData created by ShadApp is:

ThemeData(
fontFamily: themeData.textTheme.family,
extensions: themeData.extensions,
colorScheme: ColorScheme(
brightness: themeData.brightness,
primary: themeData.colorScheme.primary,
onPrimary: themeData.colorScheme.primaryForeground,
secondary: themeData.colorScheme.secondary,
onSecondary: themeData.colorScheme.secondaryForeground,
error: themeData.colorScheme.destructive,
onError: themeData.colorScheme.destructiveForeground,
surface: themeData.colorScheme.background,
onSurface: themeData.colorScheme.foreground,
),
scaffoldBackgroundColor: themeData.colorScheme.background,
brightness: themeData.brightness,
dividerTheme: DividerThemeData(
color: themeData.colorScheme.border,
thickness: 1,
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: themeData.colorScheme.primary,
selectionColor: themeData.colorScheme.selection,
selectionHandleColor: themeData.colorScheme.primary,
),
iconTheme: IconThemeData(
size: 16,
color: themeData.colorScheme.foreground,
),
scrollbarTheme: ScrollbarThemeData(
crossAxisMargin: 1,
mainAxisMargin: 1,
thickness: const WidgetStatePropertyAll(8),
radius: const Radius.circular(999),
thumbColor: WidgetStatePropertyAll(themeData.colorScheme.border),
),
),

Shadcn + Cupertino

If you need to use shadcn components with Cupertino components, use CupertinoApp instead of MaterialApp, like you are already used to.

import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ShadApp();
return ShadApp.custom(
themeMode: ThemeMode.dark,
darkTheme: ShadThemeData(
brightness: Brightness.dark,
colorScheme: const ShadSlateColorScheme.dark(),
),
appBuilder: (context) {
return CupertinoApp(
theme: CupertinoTheme.of(context),
localizationsDelegates: const [
DefaultMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
builder: (context, child) {
return ShadAppBuilder(child: child!);
},
);
},
);
}

The default CupertinoThemeData created by ShadApp is:

CupertinoThemeData(
primaryColor: themeData.colorScheme.primary,
primaryContrastingColor: themeData.colorScheme.primaryForeground,
scaffoldBackgroundColor: themeData.colorScheme.background,
barBackgroundColor: themeData.colorScheme.primary,
brightness: themeData.brightness,
),