suiss/ui · Component
Widget
A rounded card in the style of home screen widgets, with fixed sizes and optional drag-to-resize.
Widget is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Widget is a rounded muted card that comes in four sizes: small (168 × 168), medium (352 × 168), large (352 × 352) and extra-large (720 × 352), or auto to fill its parent. Compose it from WidgetHeader, which holds a WidgetIcon, WidgetTitle and an optional WidgetAction, followed by WidgetValue, WidgetDescription, WidgetContent and a WidgetFooter pinned to the bottom.
With resizable, a corner handle lets people drag the widget to another size. While dragging, a dashed outline previews the size it will snap to on release. Use widgets for glanceable summaries on a dashboard; for general grouped content, use Card.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
-
Add the
cnhelper. -
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a Widget:
Examples
Sales
Shows a resizable widget whose chart and list adapt to each size. Adapt the content to the current size with the group/widget group and data-size, for example group-data-[size=small]/widget:hidden.
Kitchen
Set handle="inside" to place the resize handle inside the widget's corner.
Reservations
Use the sizes prop to limit resizing to the small and medium sizes.
Weekly report
Starts at extra-large with defaultSize and reveals extra content only at that size.
Free resize
Set resizable="free" to follow the pointer without snapping. The widget stays between the smallest size and the largest allowed size.
Auto resize
Set size to auto to fill the parent. The widget still snaps to fixed sizes when dragged.
Centered
Centers the icon, title and description with align="center".
Sizes
Shows each fixed size side by side.
Dashboard
Arranges fixed widgets in a grid as a dashboard.
Accessibility
WidgetIconis hidden from assistive technologies, so make sure the title conveys its meaning.- The resize handle is hidden from assistive technologies and works with a pointer only. Offer another way to change the size, such as a control that sets
size, if it matters.
API Reference
Widget
The rounded card that sets the size, alignment and resize behavior.
| Prop | Type | Default |
|---|---|---|
size | WidgetSize | "auto" | - |
defaultSize | WidgetSize | "auto" | - |
onSizeChange | (size: WidgetSize | "auto") => void | - |
sizes | WidgetSize[] | ["small", "medium", "large", "extra-large"] |
resizable | boolean | "free" | false |
handle | "inside" | "outside" | "outside" |
align | "start" | "center" | "start" |
Also accepts the props of React.ComponentProps<"div">.
WidgetSize is "small" | "medium" | "large" | "extra-large", exported from @/components/ui/widget.
Use size with onSizeChange to control the size, or defaultSize to set where an uncontrolled widget starts. Without either, a resizable widget starts small and a fixed widget is auto. onSizeChange is called with the new size when a drag snaps to a different size or the size is reset. sizes lists the sizes a drag can snap to; the largest also caps free resizing.
resizable adds a resize handle: true snaps to sizes, and free follows the pointer. Double-click the handle to return to the starting size. The handle is visible on hover and always visible on touch screens, and it mirrors in right-to-left layouts. Size changes animate over 500ms, and the animation is removed when reduced motion is preferred. align="center" centers the content horizontally and vertically.
Widget sets data-size and data-align, and data-resizing while dragging. It's also a @container/widget container for container queries. Each part sets a data-slot, such as widget-handle or widget-header, for styling.
WidgetHeader
A row that holds the icon, title and action.
Also accepts the props of React.ComponentProps<"div">.
WidgetIcon
A decorative icon, shown on a tile in the default and lg sizes.
| Prop | Type | Default |
|---|---|---|
size | "default" | "sm" | "lg" | "default" |
Also accepts the props of React.ComponentProps<"span">.
sm shows the icon without a tile.
WidgetTitle
The widget's title, truncated to one line.
Also accepts the props of React.ComponentProps<"p">.
WidgetAction
A slot at the end of the header for a control; hidden when centered.
Also accepts the props of React.ComponentProps<"div">.
WidgetDescription
Secondary text that explains the content.
Also accepts the props of React.ComponentProps<"p">.
WidgetValue
A large figure in tabular numbers, such as a total or temperature.
Also accepts the props of React.ComponentProps<"p">.
WidgetContent
A flexible column that fills the remaining space.
Also accepts the props of React.ComponentProps<"div">.
WidgetFooter
Small secondary text pinned to the bottom of the widget.
Also accepts the props of React.ComponentProps<"div">.
Web preview
Widget is a View with a rounded, filled surface. It comes in four fixed sizes, small (168×168), medium (352×168), large (352×352) and extra-large (720×352), or auto, which fills its parent. Fixed sizes animate with Reanimated when the size changes.
With resizable, a corner handle lets the user drag the widget between sizes: a dashed outline previews the size it will snap to, a selection haptic plays on each new snap (when a haptics adapter is provided through HapticsContext), and double-tapping the handle returns to the initial size. Only sizes that fit the available width are offered. Set align="center" to center the content, which also hides WidgetAction.
Compose the content from WidgetHeader (with WidgetIcon, WidgetTitle and WidgetAction), then WidgetValue, WidgetDescription or WidgetContent, and WidgetFooter, which sticks to the bottom. Plain strings passed to WidgetContent and WidgetFooter are wrapped in Text.
Installation
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/widget.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/widget.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/widget.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Sizes
The four fixed sizes side by side.
Web preview
Editing
A resizable widget starting at large.

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Inside handle
A resizable widget with the handle drawn inside the corner.

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Limited sizes
Use sizes to limit resizing to small and medium.

This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Controlled
Controls the size with size and onSizeChange. Without them the size is uncontrolled, starting at defaultSize; a non-resizable widget defaults to auto and a resizable one to small.

Centered
Centered content with align="center".
Web preview
Auto
An auto widget that fills its parent.
Web preview
Dashboard
Several auto-sized widgets arranged in a grid.
Web preview
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Accessibility
- The resize handle has the
adjustablerole, itsresizeLabeland the current size as its value; increment and decrement actions step through the available sizes, so VoiceOver and TalkBack users can resize without dragging. WidgetTitlehas theheadingrole.WidgetIconand the resize preview outline are hidden from assistive technology.- Size animations respect the system reduce motion setting.
API Reference
Widget
The card surface and optional resize handle.
| Prop | Type | Default |
|---|---|---|
className | string | - |
size | WidgetSize | "auto" | - |
defaultSize | WidgetSize | "auto" | - |
onSizeChange | (size: WidgetSize | "auto") => void | - |
sizes | WidgetSize[] | ALL_SIZES |
resizable | boolean | false |
handle | WidgetHandlePlacement | "outside" |
align | WidgetAlign | "start" |
resizeLabel | string | "Resize widget" |
Also accepts the props of ViewProps, React.RefAttributes<View>.
resizeLabel is the accessibility label of the handle. The handle and drag direction mirror in right-to-left layouts. useWidget returns the current size and align so custom content can adapt to the widget size.
WidgetHeader
Row for the icon, title and action.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Also accepts the props of ViewProps, React.RefAttributes<View>.
WidgetIcon
Icon frame in default, sm or lg size.
| Prop | Type | Default |
|---|---|---|
className | string | - |
iconClassName | string | - |
size | "default" | "sm" | "lg" | "default" |
Also accepts the props of ViewProps, React.RefAttributes<View>.
WidgetTitle
Single-line heading.
Also accepts the props of Text.
WidgetAction
Trailing slot in the header; hidden when centered.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Also accepts the props of ViewProps, React.RefAttributes<View>.
WidgetDescription
Secondary text.
Also accepts the props of Text.
WidgetValue
Large number with tabular figures.
Also accepts the props of Text.
WidgetContent
Flexible body area that clips overflow.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Also accepts the props of ViewProps, React.RefAttributes<View>.
Plain strings passed to WidgetContent and WidgetFooter are wrapped in Text.
WidgetFooter
Small secondary text and icons pinned to the bottom.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Also accepts the props of ViewProps, React.RefAttributes<View>.
WidgetSize
Values: .small, .medium, .large, .extraLarge.
WidgetAlign
Values: .start, .center.
WidgetHandlePlacement
Values: .inside, .outside.
Widget
The card surface and optional resize handle.
| Parameter | Type | Default |
|---|---|---|
_ size | WidgetSize?: .small | .medium | .large | .extraLarge | .small |
align | WidgetAlign: .start | .center | .start |
content | () -> Content | - |
size | Binding<WidgetSize> | - |
sizes | [WidgetSize] | WidgetSize.allCases |
editing | Bool | - |
handle | WidgetHandlePlacement: .inside | .outside | .outside |
resetSize | WidgetSize?: .small | .medium | .large | .extraLarge | nil |
Overloads: init(_:align:content:), init(size:sizes:editing:handle:align:resetSize:content:).
WidgetHeader
Row for the icon, title and action.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
WidgetIconSize
Values: .default, .sm, .lg.
WidgetIcon
Icon frame in default, sm or lg size.
| Parameter | Type | Default |
|---|---|---|
size | WidgetIconSize: .default | .sm | .lg | .default |
content | () -> Content | - |
WidgetTitle
Single-line heading.
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
WidgetAction
Trailing slot in the header; hidden when centered.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
WidgetDescription
Secondary text.
| Parameter | Type | Default |
|---|---|---|
_ description | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
WidgetValue
Large number with tabular figures.
| Parameter | Type | Default |
|---|---|---|
_ value | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
WidgetContent
Flexible body area that clips overflow.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
WidgetFooter
Small secondary text and icons pinned to the bottom.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
_ text | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(content:), init(_:), init(verbatim:).
WidgetSize
Values: Auto, Small, Medium, Large, ExtraLarge.
WidgetHandlePlacement
Values: Inside, Outside.
WidgetAlign
Values: Start, Center.
WidgetIconSize
Values: Default, Sm, Lg.
WidgetScope
| Property | Type |
|---|---|
size | WidgetSize |
Widget
The card surface and optional resize handle.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
size | WidgetSize?: Auto | Small | Medium | Large | ExtraLarge | null |
defaultSize | WidgetSize?: Auto | Small | Medium | Large | ExtraLarge | null |
onSizeChange | ((WidgetSize) -> Unit)? | null |
sizes | List<WidgetSize> | DefaultWidgetSizes |
resizable | Boolean | false |
handle | WidgetHandlePlacement: Inside | Outside | WidgetHandlePlacement.Outside |
align | WidgetAlign: Start | Center | WidgetAlign.Start |
content | @Composable WidgetScope.() -> Unit | - |
WidgetHeader
Row for the icon, title and action.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |
WidgetIcon
Icon frame in default, sm or lg size.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
size | WidgetIconSize: Default | Sm | Lg | WidgetIconSize.Default |
content | @Composable () -> Unit | - |
WidgetTitle
Single-line heading.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
WidgetAction
Trailing slot in the header; hidden when centered.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |
WidgetDescription
Secondary text.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
WidgetValue
Large number with tabular figures.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
WidgetContent
Flexible body area that clips overflow.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |
WidgetFooter
Small secondary text and icons pinned to the bottom.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable () -> Unit | - |



