flet-box 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +10 -0
  2. package/bin/cli.js +23 -7
  3. package/bin/commands/checkApi.js +761 -0
  4. package/bin/commands/create.js +77 -5
  5. package/bin/utils/dtsProps.js +191 -0
  6. package/bin/utils/moduleExports.js +165 -0
  7. package/bin/utils/neutralise.js +64 -0
  8. package/bin/utils/templates.js +366 -27
  9. package/docs/CONTRIBUTING.md +156 -0
  10. package/docs/README.md +68 -0
  11. package/docs/arquitectura.md +164 -0
  12. package/docs/cli/README.md +542 -0
  13. package/docs/guides/README.md +33 -0
  14. package/docs/guides/app-templates.md +197 -0
  15. package/docs/guides/compatibility.md +95 -0
  16. package/docs/guides/embedding.md +284 -0
  17. package/docs/guides/first-app.md +208 -0
  18. package/docs/guides/frontend-services.md +171 -0
  19. package/docs/guides/minification-and-protection.md +260 -0
  20. package/docs/guides/mobile-and-platforms.md +439 -0
  21. package/docs/guides/online-updates.md +196 -0
  22. package/docs/guides/router.md +282 -0
  23. package/docs/guides/state.md +283 -0
  24. package/docs/guides/syntax-philosophy.md +150 -0
  25. package/docs/guides/utilities.md +241 -0
  26. package/docs/guides/widget-structure.md +163 -0
  27. package/docs/server/README.md +68 -0
  28. package/docs/server/START_HERE.md +121 -0
  29. package/docs/server/api.md +225 -0
  30. package/docs/server/data-services.md +300 -0
  31. package/docs/server/deployment.md +113 -0
  32. package/docs/server/security.md +196 -0
  33. package/docs/services/README.md +79 -0
  34. package/docs/services/RamStore.md +84 -0
  35. package/docs/services/Session.md +84 -0
  36. package/docs/services/Storage.md +88 -0
  37. package/docs/services/http.md +86 -0
  38. package/docs/tools/README.md +138 -0
  39. package/docs/tools/animation.md +87 -0
  40. package/docs/tools/async-ids-log.md +80 -0
  41. package/docs/tools/device.md +132 -0
  42. package/docs/tools/introspection.md +67 -0
  43. package/docs/tools/lists.md +96 -0
  44. package/docs/tools/markdown.md +79 -0
  45. package/docs/tools/reactivity.md +288 -0
  46. package/docs/tools/state.md +103 -0
  47. package/docs/tools/styling.md +92 -0
  48. package/docs/tools/text-and-time.md +89 -0
  49. package/docs/tools/theme.md +102 -0
  50. package/docs/tools/validation.md +75 -0
  51. package/docs/tools/visual-effects.md +84 -0
  52. package/docs/widget/Accordion.md +144 -0
  53. package/docs/widget/AdMob.md +144 -0
  54. package/docs/widget/AdSense.md +133 -0
  55. package/docs/widget/AdaptiveScaffold.md +105 -0
  56. package/docs/widget/AlertDialog.md +103 -0
  57. package/docs/widget/AnimatedBox.md +130 -0
  58. package/docs/widget/AnimatedText.md +123 -0
  59. package/docs/widget/AppBar.md +118 -0
  60. package/docs/widget/Audio.md +135 -0
  61. package/docs/widget/Avatar.md +119 -0
  62. package/docs/widget/Badge.md +128 -0
  63. package/docs/widget/BottomNavigation.md +116 -0
  64. package/docs/widget/BottomSheet.md +125 -0
  65. package/docs/widget/Button.md +137 -0
  66. package/docs/widget/COMMON_PROPS.md +150 -0
  67. package/docs/widget/Card.md +125 -0
  68. package/docs/widget/Carousel.md +151 -0
  69. package/docs/widget/Chart.md +151 -0
  70. package/docs/widget/Checkbox.md +118 -0
  71. package/docs/widget/Chip.md +126 -0
  72. package/docs/widget/CircularBar.md +168 -0
  73. package/docs/widget/CircularChart.md +164 -0
  74. package/docs/widget/CodeViewer.md +130 -0
  75. package/docs/widget/CollapsibleSideBar.md +112 -0
  76. package/docs/widget/Column.md +129 -0
  77. package/docs/widget/Container.md +136 -0
  78. package/docs/widget/DataTable.md +150 -0
  79. package/docs/widget/Divider.md +109 -0
  80. package/docs/widget/DraggBox.md +129 -0
  81. package/docs/widget/Drawer.md +135 -0
  82. package/docs/widget/DrawerItem.md +98 -0
  83. package/docs/widget/Dropdown.md +139 -0
  84. package/docs/widget/DroppBox.md +152 -0
  85. package/docs/widget/FloatingActionButton.md +120 -0
  86. package/docs/widget/GridView.md +140 -0
  87. package/docs/widget/Icon.md +117 -0
  88. package/docs/widget/Image.md +125 -0
  89. package/docs/widget/Input.md +151 -0
  90. package/docs/widget/Inspector.md +92 -0
  91. package/docs/widget/InstallButton.md +128 -0
  92. package/docs/widget/ListTile.md +132 -0
  93. package/docs/widget/ListView.md +138 -0
  94. package/docs/widget/Markdown.md +175 -0
  95. package/docs/widget/MatrixRain.md +122 -0
  96. package/docs/widget/Modal.md +129 -0
  97. package/docs/widget/Pagination.md +135 -0
  98. package/docs/widget/ParallaxBox.md +128 -0
  99. package/docs/widget/ProgressBar.md +130 -0
  100. package/docs/widget/QRCode.md +117 -0
  101. package/docs/widget/README.md +188 -0
  102. package/docs/widget/Radio.md +123 -0
  103. package/docs/widget/Rating.md +131 -0
  104. package/docs/widget/Row.md +131 -0
  105. package/docs/widget/START_HERE.md +146 -0
  106. package/docs/widget/Scaffold.md +152 -0
  107. package/docs/widget/Skeleton.md +130 -0
  108. package/docs/widget/Slider.md +146 -0
  109. package/docs/widget/SnackBar.md +102 -0
  110. package/docs/widget/Stack.md +128 -0
  111. package/docs/widget/Stepper.md +145 -0
  112. package/docs/widget/Switch.md +118 -0
  113. package/docs/widget/Tabs.md +124 -0
  114. package/docs/widget/Text.md +133 -0
  115. package/docs/widget/Tooltip.md +145 -0
  116. package/docs/widget/TreeView.md +176 -0
  117. package/docs/widget/Video.md +127 -0
  118. package/docs/widget/_template.md +61 -0
  119. package/package.json +3 -2
  120. package/src/animations/animate.js +180 -70
  121. package/src/animations/index.js +1 -0
  122. package/src/create-index.sh +1 -1
  123. package/src/index.d.ts +45 -22
  124. package/src/index.js +1 -0
  125. package/src/navigations/AdaptiveScaffold.js +11 -2
  126. package/src/navigations/BottomNavigation.js +10 -3
  127. package/src/navigations/Tabs.js +6 -2
  128. package/src/tools/useState.js +54 -63
  129. package/src/widget-factory/assignProps.js +23 -1
  130. package/src/widget-factory/processProps.js +10 -3
  131. package/src/widget-factory/reactiveValue.js +43 -18
  132. package/src/widget-factory/translateProps.js +777 -901
  133. package/src/widgets/AlertDialog.js +7 -5
  134. package/src/widgets/Checkbox.js +9 -7
  135. package/src/widgets/CircularBar.js +12 -1
  136. package/src/widgets/FloatingActionButton.js +4 -7
  137. package/src/widgets/Image.js +5 -7
  138. package/src/widgets/Input.js +92 -0
  139. package/src/widgets/ListView.js +73 -29
  140. package/src/widgets/Pagination.js +6 -3
  141. package/src/widgets/ProgressBar.js +16 -13
  142. package/src/widgets/Radio.js +6 -7
  143. package/src/widgets/Slider.js +23 -4
  144. package/src/widgets/Stack.js +36 -3
  145. package/src/widgets/Stepper.js +4 -3
  146. package/src/widgets/Switch.js +3 -4
  147. package/src/widgets/TreeView.js +0 -1
@@ -0,0 +1,119 @@
1
+ # Avatar
2
+
3
+ A compact identity chip that shows a profile image, the person's initials, or a fallback icon. It falls back gracefully when no image is available.
4
+
5
+ ## When to use it
6
+
7
+ Reach for it in headers, comments, list rows, and any place a user needs a face.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Avatar } from "flet-box";
13
+
14
+ const user = Avatar({
15
+ name: "Ada Lovelace",
16
+ });
17
+ ```
18
+
19
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
20
+
21
+ ## Props
22
+
23
+ | Prop | Type | Description |
24
+ | --- | --- | --- |
25
+ | `src` | `string` | Resource URL for the image, audio, or video. |
26
+ | `name` | `string` | The `name` value for the widget. |
27
+ | `icon` | `string` | Name of the icon to render. |
28
+ | `size` | `number` | Overall size preset or pixel value, depending on the widget. |
29
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
30
+ | `textColor` | `Color` | Color of the button label. |
31
+ | `shape` | `'circle' \| 'rounded' \| 'square'` | The `shape` value for the widget. |
32
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
33
+
34
+ ### Common props
35
+
36
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
37
+
38
+ | Prop | Type | Description |
39
+ | --- | --- | --- |
40
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
41
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
42
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
43
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
44
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
45
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
46
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
47
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
48
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
49
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
50
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
51
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
52
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
53
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
54
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
55
+ | `id` | `string` | DOM `id` for the rendered element. |
56
+ | `className` | `string` | CSS class names applied to the rendered element. |
57
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
58
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
59
+
60
+ ## Examples
61
+
62
+ ### Everyday
63
+
64
+ ```javascript
65
+ import { Avatar } from "flet-box";
66
+
67
+ const user = Avatar({
68
+ src: "/avatars/ada.png",
69
+ name: "Ada Lovelace",
70
+ size: 48,
71
+ shape: "circle",
72
+ });
73
+ ```
74
+
75
+ ### Full
76
+
77
+ ```javascript
78
+ import { Avatar } from "flet-box";
79
+
80
+ const user = Avatar({
81
+ src: "/avatars/ada.png",
82
+ name: "Ada Lovelace",
83
+ size: 64,
84
+ shape: "rounded",
85
+ bgColor: "#2563eb",
86
+ textColor: "#ffffff",
87
+ onPress: () => console.log("open profile"),
88
+ });
89
+ ```
90
+
91
+ ## Tips
92
+
93
+ - Provide both src and name so initials render if the image fails.
94
+ - Use shape: "circle" for people and shape: "rounded" for organizations or bots.
95
+
96
+ ## Accessibility
97
+
98
+ - The name prop is announced as the label, so always give a meaningful name.
99
+
100
+ ## Behavior
101
+
102
+ - When src is missing or errors, the widget automatically shows initials from name.
103
+ - onPress makes the whole avatar interactive, which is useful for opening profiles.
104
+
105
+ ## Related widgets
106
+
107
+ - [Image](Image.md)
108
+ - [ListTile](ListTile.md)
109
+ - [Card](Card.md)
110
+
111
+ ---
112
+
113
+ ## Continue reading
114
+
115
+ - **Previous:** [GridView](GridView.md)
116
+ - **Next:** [Badge](Badge.md)
117
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
118
+
119
+ You are reading **Chapter 3 · Layout, cards and lists** (6 of 8).
@@ -0,0 +1,128 @@
1
+ # Badge
2
+
3
+ Wraps a child widget and overlays a small count or status marker at one of its corners. Commonly used for notification counts.
4
+
5
+ ## When to use it
6
+
7
+ Use it to signal unseen items or status on an icon, avatar, or button.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Badge, Icon } from "flet-box";
13
+
14
+ const badge = Badge({
15
+ value: 5,
16
+ child: Icon({ name: "notifications" }),
17
+ });
18
+ ```
19
+
20
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
21
+
22
+ ## Props
23
+
24
+ | Prop | Type | Description |
25
+ | --- | --- | --- |
26
+ | `value` | `string \| number` | Current value controlled by the widget. |
27
+ | `child` | `Widget` | A single child widget. Alias: `children` for a list. |
28
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
29
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
30
+ | `size` | `number` | Overall size preset or pixel value, depending on the widget. |
31
+ | `position` | `'top-right' \| 'top-left' \| 'bottom-right' \| 'bottom-left'` | CSS `position` value, or `stack` for centered stacking. |
32
+ | `offset` | `number` | The `offset` value for the widget. |
33
+ | `borderWidth` | `number` | Width of the border. |
34
+ | `borderColor` | `Color` | Color used for the border. |
35
+ | `showZero` | `boolean` | Controls whether the zero is shown. |
36
+ | `max` | `number` | Maximum value used to compute the ratio. |
37
+
38
+ ### Common props
39
+
40
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
41
+
42
+ | Prop | Type | Description |
43
+ | --- | --- | --- |
44
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
45
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
46
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
47
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
48
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
49
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
50
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
51
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
52
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
53
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
54
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
55
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
56
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
57
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
58
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
59
+ | `id` | `string` | DOM `id` for the rendered element. |
60
+ | `className` | `string` | CSS class names applied to the rendered element. |
61
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
62
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
63
+
64
+ ## Examples
65
+
66
+ ### Everyday
67
+
68
+ ```javascript
69
+ import { Badge, Icon } from "flet-box";
70
+
71
+ const inbox = Badge({
72
+ value: 12,
73
+ max: 99,
74
+ bgColor: "#dc2626",
75
+ color: "#ffffff",
76
+ child: Icon({ name: "mail" }),
77
+ });
78
+ ```
79
+
80
+ ### Full
81
+
82
+ ```javascript
83
+ import { Badge, Icon } from "flet-box";
84
+
85
+ const inbox = Badge({
86
+ value: 120,
87
+ max: 99,
88
+ bgColor: "#dc2626",
89
+ color: "#ffffff",
90
+ size: 18,
91
+ position: "top-right",
92
+ offset: 4,
93
+ borderWidth: 2,
94
+ borderColor: "#ffffff",
95
+ showZero: false,
96
+ child: Icon({ name: "mail", size: 28 }),
97
+ });
98
+ ```
99
+
100
+ ## Tips
101
+
102
+ - Set max so large counts collapse to "99+" style displays.
103
+ - Use position and offset to place the marker precisely on irregular shapes.
104
+
105
+ ## Accessibility
106
+
107
+ - The badge value is visual only; add a Text or title nearby to convey the count.
108
+
109
+ ## Behavior
110
+
111
+ - showZero: false hides the marker entirely when value is 0.
112
+ - A borderWidth with a matching borderColor creates a clean cutout against the child.
113
+
114
+ ## Related widgets
115
+
116
+ - [Avatar](Avatar.md)
117
+ - [Icon](Icon.md)
118
+ - [Chip](Chip.md)
119
+
120
+ ---
121
+
122
+ ## Continue reading
123
+
124
+ - **Previous:** [Avatar](Avatar.md)
125
+ - **Next:** [Chip](Chip.md)
126
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
127
+
128
+ You are reading **Chapter 3 · Layout, cards and lists** (7 of 8).
@@ -0,0 +1,116 @@
1
+ # BottomNavigation
2
+
3
+ ## Overview
4
+ `BottomNavigation` renders a bottom tab bar as a `<nav>` flex row. Each `item` shows an `icon` (and an optional `label` below it). With `useRouter: true` (the default) tapping a tab calls `goTo(route)` and the active state follows the URL; with `useRouter: false` the bar keeps its own `currentIndex` and reports changes through `onTabChange`. It is sticky-sized for the bottom of a [Scaffold](Scaffold.md)'s `bottomBar` slot.
5
+
6
+ ## When to use
7
+ - Give a phone-style app its primary navigation at the bottom.
8
+ - Keep the active tab in sync with the router so deep links highlight the right tab.
9
+
10
+ ## Import
11
+
12
+ ```javascript
13
+ import { BottomNavigation } from "flet-box";
14
+ ```
15
+
16
+ ## Basic example
17
+
18
+ The smallest useful version. Start here if this widget is new to you.
19
+
20
+ ```javascript
21
+ import { BottomNavigation } from "flet-box";
22
+
23
+ BottomNavigation({
24
+ items: [
25
+ { icon: "home", label: "Home" },
26
+ { icon: "shopping_cart", label: "Cart" },
27
+ ],
28
+ useRouter: false,
29
+ });
30
+ ```
31
+
32
+ ## Props
33
+
34
+ | Prop | Type | Default | Description |
35
+ | --- | --- | --- | --- |
36
+ | `items` | array | `[]` | Tab descriptors: `{ icon, label?, route?, onPress? }`. Only `icon` is required. |
37
+ | `currentIndex` | number | `0` | Initial active tab (used only when `useRouter` is false). |
38
+ | `onTabChange` | function | — | Called with the active index after a change (and, in router mode, with the synced index). |
39
+ | `useRouter` | boolean | `true` | When true, taps call `goTo(route)` and selection follows the current path. |
40
+ | `backgroundColor` | Color | `colors.surface` | Bar background. |
41
+ | `selectedColor` | Color | `colors.primary` | Icon/label color of the active tab. |
42
+ | `unselectedColor` | Color | `colors.textSecondary` | Color of inactive tabs. |
43
+ | `showLabels` | boolean | `true` | Show the label under each icon. |
44
+ | `iconSize` | number | `24` | Icon size in pixels. |
45
+ | `height` | number | `65` | Bar height in pixels. |
46
+ | `margin`/`marginTop`/… | number or string | `0` | Outer spacing (the bar shrinks to `calc(100% - margins)`). |
47
+ | `padding` | number or string | `0` | Inner padding. |
48
+ | `borderRadius` | number or string | `0` | Corner radius. |
49
+ | `shadow` | boolean or string | `true` | `true` uses the shadow map for `elevation`; a CSS string is applied directly; `false` removes it. |
50
+ | `elevation` | number (0-5) | `2` | Shadow level used when `shadow` is `true`. |
51
+
52
+ These are the props specific to `BottomNavigation`. Item routes default to `/${label?.toLowerCase()}`, so `{ icon: "home", label: "Home" }` targets `/home`.
53
+
54
+ ## Instance methods
55
+
56
+ - `setActiveIndex(index)` — select a tab programmatically. In router mode it navigates to the item's route; otherwise it switches and fires `onTabChange`/`onPress`.
57
+ - `getActiveIndex()` — the current index.
58
+ - `getCurrentRoute()` — the current router path (always `null` when `useRouter` is false).
59
+
60
+ ## Examples
61
+
62
+ ### Everyday example
63
+
64
+ ```javascript
65
+ import { BottomNavigation } from "flet-box";
66
+
67
+ BottomNavigation({
68
+ items: [
69
+ { icon: "home", label: "Home" },
70
+ { icon: "search", label: "Search" },
71
+ { icon: "person", label: "Profile" },
72
+ ],
73
+ useRouter: false,
74
+ onTabChange: (index) => console.log("tab", index),
75
+ });
76
+ ```
77
+
78
+ ### Full example
79
+
80
+ ```javascript
81
+ import { runApp, Scaffold, Text, BottomNavigation } from "flet-box";
82
+
83
+ const app = Scaffold({
84
+ body: Text({ text: "Main screen" }),
85
+ bottomBar: BottomNavigation({
86
+ items: [
87
+ { icon: "home", label: "Home", route: "/", onPress: () => console.log("tap home") },
88
+ { icon: "settings", label: "Settings", route: "/settings" },
89
+ ],
90
+ }),
91
+ });
92
+
93
+ runApp(app, "root");
94
+ ```
95
+
96
+ ## Notes
97
+
98
+ - In router mode the bar subscribes to router changes and re-highlights on `goTo`, back, and forward navigation — one source of truth for the active tab.
99
+ - The active item gets `font-weight: 500` on its label and the selected/unselected colors on both icon and label.
100
+ - Item `onPress` fires after navigation (router mode) or after the local switch (non-router mode).
101
+ - `_cleanup` unsubscribes from the router, so removing the bar never leaves stale listeners.
102
+
103
+ ## Related widgets
104
+ - [Scaffold](Scaffold.md)
105
+ - [Tabs](Tabs.md)
106
+ - [Drawer](Drawer.md)
107
+
108
+ ---
109
+
110
+ ## Continue reading
111
+
112
+ - **Previous:** [DrawerItem](DrawerItem.md)
113
+ - **Next:** [Tabs](Tabs.md)
114
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
115
+
116
+ You are reading **Chapter 8 · App navigation** (6 of 8).
@@ -0,0 +1,125 @@
1
+ # BottomSheet
2
+
3
+ A panel that slides up from the bottom of the screen over a dimmed overlay.
4
+
5
+ ## When to use it
6
+
7
+ Use BottomSheet for short, task-focused panels such as filters, share sheets or quick forms.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { BottomSheet, Text } from "flet-box";
13
+
14
+ const sheet = BottomSheet({
15
+ content: Text({ text: "Choose an action" }),
16
+ });
17
+ ```
18
+
19
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
20
+
21
+ ## Props
22
+
23
+ | Prop | Type | Description |
24
+ | --- | --- | --- |
25
+ | `content` | `Widget` | Main content of the overlay. |
26
+ | `title` | `string` | Title text shown in the header. |
27
+ | `actions` | `Widget[]` | Widgets rendered in the overlay footer. |
28
+ | `height` | `number \| string` | Height of the widget. A number is pixels; a string uses any CSS unit. |
29
+ | `maxHeight` | `number \| string` | Maximum height the widget may grow to. |
30
+ | `showDragHandle` | `boolean` | Shows the drag handle above the sheet. |
31
+ | `closeOnOverlayClick` | `boolean` | Closes the overlay when the backdrop is clicked. |
32
+ | `closeOnDragDown` | `boolean` | Closes the sheet when dragged down. |
33
+ | `showCloseButton` | `boolean` | Shows a close button in the header. |
34
+ | `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
35
+ | `overlayColor` | `Color` | Color of the dimmed backdrop behind the overlay. |
36
+ | `dragHandleColor` | `Color` | Color used for the drag handle. |
37
+ | `headerTextColor` | `Color` | Text color of the header row. |
38
+ | `headerBorderColor` | `Color` | Border color for the header. |
39
+ | `actionBorderColor` | `Color` | Border color for the action. |
40
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
41
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
42
+ | `headerPadding` | `Padding` | Padding for the header. |
43
+ | `contentPadding` | `Padding` | Padding for the content. |
44
+ | `actionPadding` | `Padding` | Padding for the action. |
45
+ | `dragHandlePadding` | `Padding` | Padding for the drag handle. |
46
+ | `dragHandleWidth` | `number` | Width of the drag handle. |
47
+ | `dragHandleHeight` | `number` | Height of the drag handle. |
48
+ | `animationDuration` | `number` | Duration for the animation, in milliseconds. |
49
+ | `zIndex` | `number` | Index used for the z. |
50
+ | `overlayZIndex` | `number` | Index used for the overlay z. |
51
+ | `onOpen` | `() => void` | Fired when the overlay opens. |
52
+ | `onClose` | `() => void` | Fired when the overlay closes. |
53
+
54
+ ## Examples
55
+
56
+ ### Everyday
57
+
58
+ ```javascript
59
+ import { BottomSheet, Text } from "flet-box";
60
+
61
+ const sheet = BottomSheet({
62
+ title: "Share",
63
+ content: Text({ text: "Share this document with your team." }),
64
+ closeOnOverlayClick: true,
65
+ onClose: () => console.log("closed"),
66
+ });
67
+ ```
68
+
69
+ ### Full
70
+
71
+ ```javascript
72
+ import { BottomSheet, Button, Checkbox, Column, Switch, rgba } from "flet-box";
73
+
74
+ const filters = BottomSheet({
75
+ title: "Filters",
76
+ height: "60%",
77
+ showDragHandle: true,
78
+ closeOnDragDown: true,
79
+ closeOnOverlayClick: true,
80
+ showCloseButton: true,
81
+ backgroundColor: "#ffffff",
82
+ overlayColor: "rgba(15, 23, 42, 0.4)",
83
+ borderRadius: 20,
84
+ content: Column({
85
+ gap: 12,
86
+ children: [Switch({ label: "In stock" }), Checkbox({ label: "On sale" })],
87
+ }),
88
+ actions: [
89
+ Button({ text: "Reset", variant: "text" }),
90
+ Button({ text: "Apply", onPress: () => filters.close() }),
91
+ ],
92
+ onOpen: () => console.log("opened"),
93
+ onClose: () => console.log("closed"),
94
+ });
95
+ ```
96
+
97
+ ## Tips
98
+
99
+ - Reach for BottomSheet for lightweight panels and Modal when the content needs the user's full attention.
100
+ - closeOnDragDown only works together with a drag handle, so keep showDragHandle: true when enabling it.
101
+
102
+ ## Accessibility
103
+
104
+ - Give the sheet a title so the panel has an accessible name, and keep the close action reachable by keyboard.
105
+
106
+ ## Behavior
107
+
108
+ - Returns a controller with open, close, toggle and destroy; the overlay stays hidden until open() is called.
109
+ - Overlay clicks and Escape close the sheet, onOpen/onClose fire as it animates, and destroy() releases the listeners.
110
+
111
+ ## Related widgets
112
+
113
+ - [Modal](Modal.md)
114
+ - [AlertDialog](AlertDialog.md)
115
+ - [Card](Card.md)
116
+
117
+ ---
118
+
119
+ ## Continue reading
120
+
121
+ - **Previous:** [Modal](Modal.md)
122
+ - **Next:** [SnackBar](SnackBar.md)
123
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
124
+
125
+ You are reading **Chapter 4 · Feedback and overlays** (3 of 10).
@@ -0,0 +1,137 @@
1
+ # Button
2
+
3
+ Interactive button with filled, outlined, and text variants, size presets, optional icons, and press feedback.
4
+
5
+ ## When to use it
6
+
7
+ Use Button for actions such as submit, save, confirm, or any primary and secondary command.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Button } from "flet-box";
13
+
14
+ const save = Button({
15
+ text: "Save",
16
+ });
17
+ ```
18
+
19
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
20
+
21
+ ## Props
22
+
23
+ | Prop | Type | Description |
24
+ | --- | --- | --- |
25
+ | `text` | `string` | Visible text content. |
26
+ | `onPress` | `() => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
27
+ | `variant` | `'filled' \| 'outlined' \| 'text'` | Visual variation or style preset. |
28
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
29
+ | `gradient` | `string` | CSS gradient used as the fill. |
30
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
31
+ | `textColor` | `Color` | Color of the button label. |
32
+ | `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
33
+ | `fullWidth` | `boolean` | Stretches the widget to the full width of its parent. |
34
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
35
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
36
+ | `icon` | `string` | Name of the icon to render. |
37
+ | `iconLeft` | `string` | Icon shown to the left of the label. |
38
+ | `iconRight` | `string` | Icon shown to the right of the label. |
39
+ | `iconTop` | `string` | Icon shown above the label. |
40
+ | `iconBottom` | `string` | Icon shown below the label. |
41
+ | `iconPosition` | `'left' \| 'right' \| 'top' \| 'bottom'` | Where the icon sits relative to the label. |
42
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
43
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
44
+
45
+ ### Common props
46
+
47
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
48
+
49
+ | Prop | Type | Description |
50
+ | --- | --- | --- |
51
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
52
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
53
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
54
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
55
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
56
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
57
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
58
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
59
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
60
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
61
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
62
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
63
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
64
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
65
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
66
+ | `id` | `string` | DOM `id` for the rendered element. |
67
+ | `className` | `string` | CSS class names applied to the rendered element. |
68
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
69
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
70
+
71
+ ## Examples
72
+
73
+ ### Everyday
74
+
75
+ ```javascript
76
+ import { Button } from "flet-box";
77
+
78
+ const save = Button({
79
+ text: "Save",
80
+ bgColor: "#2563eb",
81
+ color: "#ffffff",
82
+ borderRadius: 8,
83
+ onPress: () => console.log("saved"),
84
+ });
85
+ ```
86
+
87
+ ### Full
88
+
89
+ ```javascript
90
+ import { Button } from "flet-box";
91
+
92
+ const checkout = Button({
93
+ text: "Checkout",
94
+ variant: "filled",
95
+ size: "large",
96
+ gradient: "linear-gradient(90deg, #2563eb, #7c3aed)",
97
+ color: "#ffffff",
98
+ icon: "shopping_cart",
99
+ iconPosition: "right",
100
+ borderRadius: 28,
101
+ elevation: 3,
102
+ fullWidth: true,
103
+ onPress: () => console.log("checkout"),
104
+ });
105
+ ```
106
+
107
+ ## Tips
108
+
109
+ - `variant` defaults to `"filled"`; switch to `"outlined"` or `"text"` for secondary actions.
110
+ - Place icons with `icon` and `iconPosition`, or use the explicit `iconLeft`, `iconRight`, `iconTop`, `iconBottom` props.
111
+ - Setting `disabled` also drops the click handler, not just the styling.
112
+
113
+ ## Accessibility
114
+
115
+ - Always pass `text` so the button has an accessible name, and use `disabled` rather than only dimming colors.
116
+
117
+ ## Behavior
118
+
119
+ - Size presets control padding, font size, and icon size; `fullWidth` stretches the button to 100%.
120
+ - `onPress` receives no arguments and is wired to the native click; `elevation` picks a shadow level.
121
+
122
+ ## Related widgets
123
+
124
+ - [Icon](Icon.md)
125
+ - [Row](Row.md)
126
+ - [Column](Column.md)
127
+ - [FloatingActionButton](FloatingActionButton.md)
128
+
129
+ ---
130
+
131
+ ## Continue reading
132
+
133
+ - **Previous:** [Image](Image.md)
134
+ - **Next:** [Input](Input.md)
135
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
136
+
137
+ You are reading **Chapter 2 · Interaction basics** (1 of 8).