Stockholm UI Library
repository·master·Indexed 40 days ago
https://github.com/serverpod/stockholmA desktop-optimized UI library providing widgets and themes for macOS and Windows, specifically tailored for the Serverpod GUI ecosystem. It includes specialized components such as StockholmButton, StockholmPopupMenuButton, StockholmPropertyInspector, and constrained input widgets for integers, doubles, and booleans.
What's inside Stockholm
- Stockholm is a collection of desktop-first widgets and themes optimized for macOS and Windows. The library provides UI components that feel comfortable on desktop platforms without attempting to perfectly replicate native OS components. It is primarily designed for use with the Serverpod GUI.
How to use Stockholm widgets and themes
masterStockholm widgets are designed to be used with specific theme classes. To ensure the UI renders correctly and looks as intended, you must use the provided theme classes. For a complete implementation guide, refer to the example project which demonstrates the usage of all available widgets.How StockholmPropertyInspector context works
masterTheStockholmPropertyInspectoracts as a provider for layout configuration. Specialized property widgets useStockholmPropertyInspector.of(context)to look up the nearest ancestor inspector. This allows child widgets to automatically adjust their alignment, padding, and name widths to match the parent inspector's configuration without manual passing of parameters.Display single-line properties with StockholmPIOneLineProp
masterUse
StockholmPIOneLinePropfor simple key-value pairs that fit on a single line. It aligns the property name and the value widget side-by-side.name: The label for the property.value: The widget displaying the value.nameAlignment: The alignment of the name text (defaults toTextAlign.end).
StockholmPIOneLineProp( name: 'Username', value: Text('jdoe'), nameAlignment: TextAlign.start, );Use the StockholmButton widget
masterThe
StockholmButtonis a styled Material button used for primary actions. It supports different visual states such asimportant(primary color) andlarge(increased height and text style). It automatically adjusts its border radius based on the platform (Windows uses a radius of 3, others use 6).StockholmButton( onPressed: () => print('Pressed!'), child: Text('Click Me'), important: true, large: true, padding: EdgeInsets.symmetric(horizontal: 16), )Use the StockholmToolbarButton widget
masterThe
StockholmToolbarButtonis a specialized button designed for use within aStockholmToolbar. It can display an icon, an optional text label, or both.Properties
icon: (Required) TheIconDatato display.onPressed: (Required) The callback function triggered when the button is pressed.label: An optional string to display next to the icon.minWidth: The minimum width of the button (defaults to32.0).color: The color of the icon. If null, it uses the theme'siconTheme.color.selected: A boolean that, if true, applies the theme'shighlightColorto the button background.iconSize: The size of the icon (defaults to18.0).iconScale: A multiplier to scale the icon viaTransform.scale(defaults to1.0).padding: The internal padding of the button (defaults toEdgeInsets.symmetric(horizontal: 8)).height: The height of the button (defaults to32.0).
StockholmToolbarButton( icon: Icons.settings, label: 'Settings', onPressed: () => handleSettings(), selected: isSettingsOpen, )Lighten or darken colors using ColorExt
masterThe
ColorExtextension adds utility methods to any FlutterColorto adjust its lightness using HSL manipulation.darken([double amount = .1]): Returns a new color with reduced lightness.amountmust be between 0.0 and 1.0.lighten([double amount = .1]): Returns a new color with increased lightness.amountmust be between 0.0 and 1.0.
Color baseColor = Colors.blue; Color darkerColor = baseColor.darken(0.2); Color lighterColor = baseColor.lighten(0.1);Display lists of items with StockholmPIListProp
masterUse
StockholmPIListPropto display a collection of widgets within a scrollable, styled container inside the inspector. If the list is empty or null, it displays a fallback text.name: The label for the list.fallbackText: Text to show when the list is empty.list: The list of widgets to display.height: The height of the list container (defaults to200.0).trailing: An optional widget to display next to the name.
StockholmPIListProp( name: 'Tags', fallbackText: 'No tags assigned', list: [ Text('Flutter'), Text('Dart'), ], );Use the StockholmToolbar widget
masterThe
StockholmToolbaris a container widget used to display a row of interactive elements or information. It supports different placements and automatic border styling based on its position.Configuration
children: A list of widgets to display in the toolbar.backgroundColor: An optional color for the toolbar background.placement: Determines where the toolbar is located and which border side is drawn. UseStockholmToolbarPlacement.toporStockholmToolbarPlacement.bottom.
When
placementistop, a bottom border is drawn using the theme'sdividerColor. Whenbottom, a top border is drawn.StockholmToolbar( placement: StockholmToolbarPlacement.top, backgroundColor: Colors.white, children: [ StockholmToolbarButton( icon: Icons.add, onPressed: () => print('Added'), ), ], )Use StockholmPICheckboxProp for boolean values
masterUse
StockholmPICheckboxPropto display an interactive checkbox for boolean properties.name: The label for the checkbox.value: The current boolean state.onChanged: Callback triggered when the user toggles the checkbox.enabled: Whether the checkbox is interactive (defaults totrue).
StockholmPICheckboxProp( name: 'Active', value: isActive, onChanged: (bool? newValue) { setState(() => isActive = newValue ?? false); }, );showStockholmProgressDialog
masterA helper function to display a
StockholmProgressDialogusing Flutter'sshowDialog. It setsbarrierDismissible: falseby default, ensuring the user cannot dismiss the progress dialog by tapping outside of it.showStockholmProgressDialog( context: context, builder: (context) => StockholmProgressDialog( title: Text('Title'), controller: myController, ), );Display multi-line or large properties with StockholmPILargeProp
masterUse
StockholmPILargePropwhen a property value requires more space (e.g., a large text block or a nested list). The name is placed above the value, and the value can span multiple lines.name: The label for the property.value: The widget containing the large value.trailing: An optional widget to display on the same line as the name (e.g., an icon or badge).
StockholmPILargeProp( name: 'Description', value: Text('This is a very long description that needs multiple lines.'), trailing: Icon(Icons.info), );