Skip to content
Get started
Menu
Get started

Theming

Every widget takes its colors, radius, spacing and amount style from PaymentTheme, a ThemeExtension. Register it on ThemeData.extensions. When no extension is installed, widgets fall back to PaymentTheme.fromColorScheme, so the kit follows your ColorScheme by default and a full brand is opt-in.

Buttons also support a dedicated PaymentButtonTheme and per-instance PaymentButtonStyle. See Button customization for precedence, supported properties and preserved states; these overrides do not change other component families.

Fields (text, search, text area, select, date, date range and currency) have a dedicated PaymentFieldTheme for fill, resting outline, corners and input typography, with no per-field style. See Text field customization.

Material component themes are partially inherited. Primary/destructive PaymentButtons set background/foreground colors (including disabled colors), shape and text style. The kit owns every button size property (D118): minimum, fixed and maximum size, padding, tap-target size and visual density, so a host filledButtonTheme fixedSize cannot stretch a small button past its 36 dp visual height. Properties the kit leaves unset, such as overlay color, still inherit.

Fields set resting, focus, error and disabled borders, label/hint styles and helper/error line limits; field callers supply content padding. Without PaymentFieldTheme.fillColor, decoration filled and fillColor remain unset, so host inputDecorationTheme fill settings can show through.

Use PaymentButtonTheme and PaymentFieldTheme for supported, stable customization, and check host Material properties that can leak into kit controls. These extensions do not clear unrelated host Material properties. See existing-app adoption.

Other component families read the shared theme. Scope PaymentTheme to a feature to change its appearance; toasts capture the caller’s scoped themes when shown. The host checkout example shares a button theme, field theme and named pay-button preset across two layouts.

final scheme = ColorScheme.fromSeed(seedColor: brandColor);
ThemeData(
colorScheme: scheme,
extensions: [
PaymentTheme.fromColorScheme(scheme).copyWith(accent: brandColor, radius: 12),
],
);

Status tones (info, success, warning, danger) are fixed, contrast-checked values in fromColorScheme: at least 5.8:1 on white in light mode and 7.6:1 on #131417 in dark mode, so status text stays readable whatever your seed color is. neutral follows the scheme.

Build one PaymentTheme per brightness. This is the example app’s default brand, “Hairline” (white page, navy-black ink, rules instead of cards), copied from example/lib/themes.dart:

ThemeData buildTheme(Brightness brightness) {
final dark = brightness == Brightness.dark;
final ink = dark ? const Color(0xFFECEDF0) : const Color(0xFF1A1F36);
final surface = dark ? const Color(0xFF131417) : Colors.white;
final scheme = ColorScheme.fromSeed(
seedColor: const Color(0xFF1A1F36),
brightness: brightness,
dynamicSchemeVariant: DynamicSchemeVariant.monochrome,
primary: ink,
onPrimary: surface,
surface: surface,
onSurface: ink,
);
final payment = PaymentTheme.fromColorScheme(scheme).copyWith(
accent: ink,
onAccent: surface,
surface: surface,
surfaceMuted: dark ? const Color(0xFF1C1E23) : const Color(0xFFF5F6F8),
outline: dark ? const Color(0xFF2C2E35) : const Color(0xFFE3E6EC),
textPrimary: ink,
textSecondary: dark ? const Color(0xFFA2A8B5) : const Color(0xFF5E6678),
// Control edge 3.37:1 light, 4.85:1 dark.
border: dark ? const Color(0xFF7E838E) : const Color(0xFF868C9A),
disabled: dark ? const Color(0xFF62656E) : const Color(0xFFA6ABB5),
);
return ThemeData(colorScheme: scheme, extensions: [payment]);
}

Pass theme: buildTheme(Brightness.light) and darkTheme: buildTheme(Brightness.dark) to MaterialApp.

Gallery checkout specimens in the Hairline brand: merchant header, step indicator and order summary.Gallery checkout specimens in the Hairline brand: merchant header, step indicator and order summary.
Hairline (follows the site theme)
The same checkout specimens in the Lumen brand: pure black and white, heavier amounts.
Lumen: the same widgets, other tokens

The second brand, Lumen, is also in example/lib/themes.dart: pure black and white, amountWeight: FontWeight.w700, its own muted and outline colors. All three brands, Soft included, are applied from outside the package without forking it.

Soft (DemoBrand.soft) uses a tinted page, white or lifted panels, an indigo accent and rounder corners: 8 dp for tags, 12 for controls, 16 for boxes and 20 for sheets. It also sets a white field fill through PaymentFieldTheme and a lighter amount weight. SoftInsetPanel in example/lib/compositions/ provides the host panel around the block.

Merchant Overview in the Soft host preset: a white inset panel with rounder corners on a tinted page, indigo accent and lighter balance.Merchant Overview in the Soft host preset: a white inset panel with rounder corners on a tinted page, indigo accent and lighter balance.
Soft: Merchant overview in a host inset panel

On the tinted light page, secondary text is 5.6:1, the accent 6.3:1, the control edge 3.5:1 and the status tones at least 5.6:1. Targets stay at least 48 dp. Full-width buttons keep their pressed layer without scaling. Charts retain their shared color ramps and dash patterns; there is no series palette API. Run it from example/:

Terminal window
flutter run -d <device-id> -t lib/soft_merchant_demo.dart
Source: themes.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:rakit_ui/rakit_ui.dart';
/// Three independent brands applied from outside the package, without forking.
enum DemoBrand { ruangBayar, lumen, soft }
ThemeData buildTheme(DemoBrand brand, Brightness brightness) {
final dark = brightness == Brightness.dark;
switch (brand) {
case DemoBrand.ruangBayar:
// "Hairline": white page, navy-black ink, rules instead of cards.
// Colors are contrast-checked in docs/design-research.md, section 0.
final ink = dark ? const Color(0xFFECEDF0) : const Color(0xFF1A1F36);
final surface = dark ? const Color(0xFF131417) : Colors.white;
final scheme = ColorScheme.fromSeed(
seedColor: const Color(0xFF1A1F36),
brightness: brightness,
dynamicSchemeVariant: DynamicSchemeVariant.monochrome,
primary: ink,
onPrimary: surface,
surface: surface,
onSurface: ink,
);
final payment = PaymentTheme.fromColorScheme(scheme).copyWith(
accent: ink,
onAccent: surface,
surface: surface,
surfaceMuted: dark ? const Color(0xFF1C1E23) : const Color(0xFFF5F6F8),
outline: dark ? const Color(0xFF2C2E35) : const Color(0xFFE3E6EC),
textPrimary: ink,
textSecondary: dark ? const Color(0xFFA2A8B5) : const Color(0xFF5E6678),
// Control edge 3.37:1 light, 4.85:1 dark; disabled labels stay above
// 2:1 on the muted fill.
border: dark ? const Color(0xFF7E838E) : const Color(0xFF868C9A),
disabled: dark ? const Color(0xFF62656E) : const Color(0xFFA6ABB5),
);
return _base(scheme, payment, background: surface);
case DemoBrand.lumen:
// "Contrast": pure black and white and heavier amounts, with the same
// corners as Hairline (radius 8).
final ink = dark ? Colors.white : Colors.black;
final surface = dark ? const Color(0xFF0F0F0F) : Colors.white;
final scheme = ColorScheme.fromSeed(
seedColor: Colors.black,
brightness: brightness,
dynamicSchemeVariant: DynamicSchemeVariant.monochrome,
primary: ink,
onPrimary: surface,
surface: surface,
onSurface: ink,
);
final payment = PaymentTheme.fromColorScheme(scheme).copyWith(
accent: ink,
onAccent: surface,
surface: surface,
surfaceMuted: dark ? const Color(0xFF1F1F1F) : const Color(0xFFF3F3F3),
outline: dark ? const Color(0xFF333333) : const Color(0xFFE8E8E8),
textPrimary: ink,
textSecondary: dark ? const Color(0xFFB3B3B3) : const Color(0xFF545454),
radius: 8,
amountWeight: FontWeight.w700,
);
return _base(scheme, payment, background: surface);
case DemoBrand.soft:
// "Soft": a tinted page with white inset panels, an indigo accent,
// rounder corners and a lighter amount. Tokens only; the panels are
// host styling (SoftInsetPanel). Contrast on the tinted page: body
// text 14.3:1, secondary 5.6:1, accent 6.3:1, control edge 3.5:1,
// status tones at least 5.6:1 (docs/design-research.md, section 9).
final page = dark ? const Color(0xFF0E0F13) : const Color(0xFFF1F2F6);
final surface = dark ? const Color(0xFF18191E) : Colors.white;
final ink = dark ? const Color(0xFFECEDF1) : const Color(0xFF1C2133);
final accent = dark ? const Color(0xFFAEB7FF) : const Color(0xFF3D4AC4);
final onAccent = dark ? page : Colors.white;
final scheme = ColorScheme.fromSeed(
seedColor: const Color(0xFF3D4AC4),
brightness: brightness,
primary: accent,
onPrimary: onAccent,
surface: surface,
onSurface: ink,
);
final payment = PaymentTheme.fromColorScheme(scheme).copyWith(
accent: accent,
onAccent: onAccent,
surface: surface,
surfaceMuted: dark ? const Color(0xFF212329) : const Color(0xFFF4F5F9),
outline: dark ? const Color(0xFF2E3038) : const Color(0xFFE2E4EB),
textPrimary: ink,
textSecondary: dark ? const Color(0xFFA4AAB7) : const Color(0xFF586074),
border: dark ? const Color(0xFF7F8592) : const Color(0xFF7A8090),
disabled: dark ? const Color(0xFF62656E) : const Color(0xFFA3A8B4),
// D101 radius roles: 8 tags, 12 controls, 16 boxes, 20 sheets.
radius: 16,
controlRadius: 12,
sheetRadius: 20,
amountWeight: FontWeight.w500,
);
// D102: fields stay white on the tinted page.
return _base(
scheme,
payment,
background: page,
field: PaymentFieldTheme(fillColor: surface),
);
}
}
ThemeData _base(
ColorScheme scheme,
PaymentTheme payment, {
required Color background,
PaymentFieldTheme? field,
}) {
final controlRadius = payment.controlBorderRadius;
return ThemeData(
colorScheme: scheme,
useMaterial3: true,
splashFactory: switch (defaultTargetPlatform) {
TargetPlatform.iOS => NoSplash.splashFactory,
TargetPlatform.android when !kIsWeb => InkSparkle.splashFactory,
_ => null,
},
scaffoldBackgroundColor: background,
extensions: [payment, ?field],
dividerTheme: DividerThemeData(color: payment.outline, space: 1),
appBarTheme: AppBarTheme(
backgroundColor: background,
foregroundColor: payment.textPrimary,
surfaceTintColor: Colors.transparent,
scrolledUnderElevation: 0,
centerTitle: false,
titleTextStyle: TextStyle(
fontSize: 17,
height: 24 / 17,
letterSpacing: 0,
fontWeight: FontWeight.w600,
color: payment.textPrimary,
),
shape: Border(bottom: BorderSide(color: payment.outline)),
),
// Demo/Scenarios/Gallery switcher: a plain bar with a hairline, the
// selected destination in ink, no tonal pill.
navigationBarTheme: NavigationBarThemeData(
backgroundColor: background,
surfaceTintColor: Colors.transparent,
indicatorColor: Colors.transparent,
height: 64,
iconTheme: WidgetStateProperty.resolveWith(
(states) => IconThemeData(
size: 24,
color: states.contains(WidgetState.selected)
? payment.textPrimary
: payment.textSecondary,
),
),
labelTextStyle: WidgetStateProperty.resolveWith(
(states) => TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: states.contains(WidgetState.selected)
? payment.textPrimary
: payment.textSecondary,
),
),
),
snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: controlRadius),
),
dialogTheme: DialogThemeData(
backgroundColor: payment.surface,
surfaceTintColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: payment.sheetBorderRadius),
),
bottomSheetTheme: BottomSheetThemeData(
backgroundColor: payment.surface,
surfaceTintColor: Colors.transparent,
),
popupMenuTheme: PopupMenuThemeData(
color: payment.surface,
surfaceTintColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: controlRadius,
side: BorderSide(color: payment.outline),
),
),
// Plain Material buttons in example screens match PaymentButton: 6 px
// corners, ink outline, no pill.
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
shape: RoundedRectangleBorder(borderRadius: controlRadius),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
foregroundColor: payment.textPrimary,
side: BorderSide(color: payment.border),
shape: RoundedRectangleBorder(borderRadius: controlRadius),
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: payment.textPrimary,
shape: RoundedRectangleBorder(borderRadius: controlRadius),
),
),
// Chips in example screens (sheet filters, the scenario picker): small
// corners, no check mark, selection shown by an ink outline.
chipTheme: ChipThemeData(
showCheckmark: false,
backgroundColor: payment.surface,
selectedColor: payment.surfaceMuted,
side: WidgetStateBorderSide.resolveWith(
(states) => BorderSide(
color: states.contains(WidgetState.selected)
? payment.accent
: payment.outline,
),
),
shape: RoundedRectangleBorder(borderRadius: controlRadius),
labelStyle: TextStyle(fontSize: 14, color: payment.textPrimary),
),
checkboxTheme: CheckboxThemeData(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: payment.surface,
border: OutlineInputBorder(
borderRadius: controlRadius,
borderSide: BorderSide(color: payment.textSecondary),
),
enabledBorder: OutlineInputBorder(
borderRadius: controlRadius,
borderSide: BorderSide(color: payment.border),
),
focusedBorder: OutlineInputBorder(
borderRadius: controlRadius,
borderSide: BorderSide(color: payment.accent, width: 2),
),
),
);
}
Source: compositions/soft_inset_panel.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/material.dart';
import 'package:rakit_ui/rakit_ui.dart';
/// Host styling for the Soft preset, not a kit component: a white panel
/// inset from the tinted page, with a thin outline and the sheet corners.
///
/// Wrap a whole scrolling block in it. The panel clips its child to the
/// rounded corners, so the block scrolls under its own edge. It adds no
/// shadow, no scale and no motion, and it keeps the kit's 48 dp targets and
/// text scaling, because it only frames the block.
class SoftInsetPanel extends StatelessWidget {
const SoftInsetPanel({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final shape = RoundedRectangleBorder(
borderRadius: theme.sheetBorderRadius,
side: BorderSide(color: theme.outline),
);
final inset = theme.space(PaymentSpace.related);
return Padding(
padding: EdgeInsets.fromLTRB(inset, inset, inset, 0),
child: Material(
color: theme.surface,
shape: shape,
clipBehavior: Clip.antiAlias,
child: child,
),
);
}
}
Source: soft_merchant_demo.dart

Open this file on GitHub. Copy and adapt it in your host app.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'merchant_demo.dart';
import 'themes.dart';
/// The Merchant overview block in the Soft host preset: the same widgets and
/// fixture as `merchant_demo.dart`, other tokens, and a host inset panel.
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
runApp(const MerchantDemo(brand: DemoBrand.soft));
}

Your app controls system bars. On Android 15 and later, the navigation-bar contrast scrim can follow the window theme while your app uses another theme. Enable edge-to-edge in main(), then wrap the app in an AnnotatedRegion inside MaterialApp.builder. That context reads the resolved app theme, including an in-app theme switch.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
runApp(const MyApp());
}
// Inside MyApp.build:
MaterialApp(
theme: buildTheme(Brightness.light),
darkTheme: buildTheme(Brightness.dark),
themeMode: themeMode,
builder: (context, child) => AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarContrastEnforced: false,
systemNavigationBarIconBrightness:
Theme.of(context).brightness == Brightness.dark
? Brightness.light
: Brightness.dark,
),
child: child!,
),
home: home,
);

The transparent bar and divider let the app surface continue behind gesture and three-button navigation. Light icons belong on dark surfaces, dark icons on light surfaces. Status-bar fields stay null so the app bar keeps control of the status bar. The kit sets no SystemUiOverlayStyle.

The full token reference, with swatches and values, is in Foundations: Color, Typography and Spacing and radius. The tokens that matter most when you set a brand:

  • outline is the decorative hairline: dividers, the method-group edge, the action-bar top. It may sit below 3:1.
  • border is the edge of a control (inputs, secondary buttons, unselected checkboxes) and must reach 3:1 against surface. It defaults to textSecondary a quarter of the way to surface.
  • disabled is the label and icon color of a disabled control on surfaceMuted.
  • radius is the corner radius of selectable boxes such as the method list, and the base of the other corner roles: tags use half of it, controls three quarters, sheets one and a half. To change one role on its own, see Corner roles.
  • spacing is the base unit (default 8). Layouts use multiples by role: inline 4, related 8, block 12, group 16, section 24, major 32.
  • amountWeight and amountFontFamily style money. Amounts use tabular figures.
  • referenceFontFamily is for things people copy or compare digit by digit: virtual account numbers, transaction IDs, promo codes. It defaults to the platform monospace.

The package bundles no fonts. Use your app’s text theme for everything else.

Without corner overrides, the base radius is 8 dp:

Role Default Derivation
Box 8 dp radius
Control 6 dp radius * 0.75
Sheet/dialog 12 dp radius * 1.5
Tag 4 dp radius * 0.5

PaymentType takes the font family and fallback from textTheme.bodyMedium, but defines its own sizes and line heights: body 15/22, label and heading 15/20, input 16/24, title 17/24, caption 13/18 and tag 12/16. Changing the host’s body-medium font size does not resize these roles. Text still follows the ambient text scaler. Use PaymentButtonTheme for button typography and PaymentFieldTheme.textStyle for entered text/placeholders; field labels and helper/error text keep their roles. See existing-app adoption for a complete brand bridge.

Default corners beside a product theme with square boxes, pill badges, unchanged controls and rounder sheets.Default corners beside a product theme with square boxes, pill badges, unchanged controls and rounder sheets.
Independent corner roles

Most brands only set radius, and every corner follows it. When one role needs its own shape, set it on the theme once. Here boxes are square, tags are pills, sheets are rounder and controls keep their default 6:

PaymentTheme.fromColorScheme(scheme).copyWith(
radius: 0, // boxes such as the method list
tagRadius: 999, // badges and tags
controlRadius: 6, // buttons, inputs, notices, menus
sheetRadius: 20, // sheet tops and dialogs
);

Leave a role unset and it keeps its multiple of radius: tag 0.5, control 0.75, sheet 1.5. Zero gives square corners; values must be finite and not negative. Components read the roles through the theme, so call sites need no style. A light/dark switch animates from the corner each theme draws, including a derived one.

copyWith keeps a role once set; passing null does not reset it. Build a new PaymentTheme to go back to the derived value. To change only buttons, use PaymentButtonTheme instead; to change only fields, use PaymentFieldTheme.

The example’s compositions/host_checkout.dart uses one host model and callback set for these two arrangements. ProductLooks installs reusable Button and Field themes while preserving other extensions; payActionStyle(context) resolves a shared host preset from current tokens. Everyday controls use those defaults. The invoice stacks method choice and receipt details; the wallet review groups balance and review content and ends with an action bar.

Invoice checkout with merchant, visible fees, payment methods, receipt email and a pill pay action.Invoice checkout with merchant, visible fees, payment methods, receipt email and a pill pay action.
Invoice checkout
Wallet checkout with the verified merchant, order reference, balance, fee summary and Pay from wallet button.Wallet checkout with the verified merchant, order reference, balance, fee summary and Pay from wallet button.
Wallet review

These are editable host examples. Routing, quotes, payment effects and eligibility remain host-owned; the kit supplies the controls and presentation contracts.

PaymentTheme

class PaymentTheme extends ThemeExtension<PaymentTheme> · lib/src/foundation/payment_theme.dart

Brand tokens for every rakit_ui widget.

Register it on ThemeData.extensions. Widgets fall back to PaymentTheme.fromColorScheme when no extension is installed, so the kit follows the host ColorScheme by default and a full brand is opt-in.

ParameterTypeDefaultDescription
accent:requiredColor——
onAccent:requiredColor——
surface:requiredColor——
surfaceMuted:requiredColor——
outline:requiredColor—Hairline rule, decorative: dividers, the method-group edge and the action-bar top. It may sit below 3:1; control edges use border.
textPrimary:requiredColor——
textSecondary:requiredColor——
neutral:requiredToneColors——
info:requiredToneColors——
success:requiredToneColors——
warning:requiredToneColors——
danger:requiredToneColors——
radius:double8Corner radius of selectable boxes such as the method list (the box role). It is also the base of the other corner roles: tags use half of it, controls three quarters and sheets one and a half, unless tagRadius, controlRadius or sheetRadius sets that role (D101).
tagRadius:double?—Corner radius of badges and tags. Null derives radius * 0.5. Zero gives square corners; a large value such as 999 gives pills.
controlRadius:double?—Corner radius of buttons, inputs, notices and menus. Null derives radius * 0.75.
sheetRadius:double?—Corner radius of sheet tops and dialogs. Null derives radius * 1.5.
spacing:double8Base spacing unit. Kit widgets never multiply it by hand; they resolve a named role with space (D46), one value per role:

* inline (4): label → caption, title → message, title → meta. * related (8): between actions and chips, text → trailing control. * block (12): icon → text, list row and header padding, notice padding. * group (16): screen, sheet and field gutters, label → value. * section (24): content → primary action, between field groups. * major (32): the largest gap; no kit widget uses it today.

amountWeight:FontWeightFontWeight.w600—
amountFontFamily:String?——
border:Color?—Edge of a control: inputs, secondary buttons, unselected checkboxes. Unlike outline it must reach 3:1 against surface. Defaults to textSecondary a quarter of the way to surface.
disabled:Color?—Label and icon color of a disabled control, drawn on surfaceMuted. Defaults to textSecondary 45% of the way to surface.
referenceFontFamily:String?—Font for references people copy or compare: virtual account numbers, transaction IDs, promo codes. Defaults to the platform monospace.

PaymentTheme.fromColorScheme(…) — Derives tokens from a Material ColorScheme.

ParameterTypeDefaultDescription
schemerequiredpositionalColorScheme——

ToneColors

class ToneColors · lib/src/foundation/payment_theme.dart

Foreground/container pair for one StatusTone.

ParameterTypeDefaultDescription
foreground:requiredColor——
container:requiredColor——

StatusTone

enum StatusTone · lib/src/foundation/payment_theme.dart

Semantic tone of a status. Widgets always pair a tone with an icon and a text label, so color is never the only signal.

ValueDescription
neutral—
info—
success—
warning—
danger—

PaymentTheme.copyWith accepts every constructor parameter, including border, disabled and referenceFontFamily.