flet-box 1.0.3 → 1.0.5
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.
- package/README.md +10 -0
- package/bin/cli.js +15 -0
- package/bin/commands/checkApi.js +761 -0
- package/bin/commands/create.js +77 -5
- package/bin/utils/dtsProps.js +191 -0
- package/bin/utils/moduleExports.js +165 -0
- package/bin/utils/neutralise.js +64 -0
- package/bin/utils/templates.js +366 -27
- package/docs/CONTRIBUTING.md +156 -0
- package/docs/README.md +68 -0
- package/docs/arquitectura.md +164 -0
- package/docs/cli/README.md +542 -0
- package/docs/guides/README.md +33 -0
- package/docs/guides/app-templates.md +197 -0
- package/docs/guides/compatibility.md +95 -0
- package/docs/guides/embedding.md +284 -0
- package/docs/guides/first-app.md +208 -0
- package/docs/guides/frontend-services.md +171 -0
- package/docs/guides/minification-and-protection.md +260 -0
- package/docs/guides/mobile-and-platforms.md +439 -0
- package/docs/guides/online-updates.md +196 -0
- package/docs/guides/router.md +282 -0
- package/docs/guides/state.md +283 -0
- package/docs/guides/syntax-philosophy.md +150 -0
- package/docs/guides/utilities.md +241 -0
- package/docs/guides/widget-structure.md +163 -0
- package/docs/server/README.md +68 -0
- package/docs/server/START_HERE.md +121 -0
- package/docs/server/api.md +225 -0
- package/docs/server/data-services.md +300 -0
- package/docs/server/deployment.md +113 -0
- package/docs/server/security.md +196 -0
- package/docs/services/README.md +79 -0
- package/docs/services/RamStore.md +84 -0
- package/docs/services/Session.md +84 -0
- package/docs/services/Storage.md +88 -0
- package/docs/services/http.md +86 -0
- package/docs/tools/README.md +138 -0
- package/docs/tools/animation.md +87 -0
- package/docs/tools/async-ids-log.md +80 -0
- package/docs/tools/device.md +132 -0
- package/docs/tools/introspection.md +67 -0
- package/docs/tools/lists.md +96 -0
- package/docs/tools/markdown.md +79 -0
- package/docs/tools/reactivity.md +288 -0
- package/docs/tools/state.md +103 -0
- package/docs/tools/styling.md +92 -0
- package/docs/tools/text-and-time.md +89 -0
- package/docs/tools/theme.md +102 -0
- package/docs/tools/validation.md +75 -0
- package/docs/tools/visual-effects.md +84 -0
- package/docs/widget/Accordion.md +144 -0
- package/docs/widget/AdMob.md +144 -0
- package/docs/widget/AdSense.md +133 -0
- package/docs/widget/AdaptiveScaffold.md +105 -0
- package/docs/widget/AlertDialog.md +103 -0
- package/docs/widget/AnimatedBox.md +130 -0
- package/docs/widget/AnimatedText.md +123 -0
- package/docs/widget/AppBar.md +118 -0
- package/docs/widget/Audio.md +135 -0
- package/docs/widget/Avatar.md +119 -0
- package/docs/widget/Badge.md +128 -0
- package/docs/widget/BottomNavigation.md +116 -0
- package/docs/widget/BottomSheet.md +125 -0
- package/docs/widget/Button.md +137 -0
- package/docs/widget/COMMON_PROPS.md +150 -0
- package/docs/widget/Card.md +125 -0
- package/docs/widget/Carousel.md +151 -0
- package/docs/widget/Chart.md +151 -0
- package/docs/widget/Checkbox.md +118 -0
- package/docs/widget/Chip.md +126 -0
- package/docs/widget/CircularBar.md +168 -0
- package/docs/widget/CircularChart.md +164 -0
- package/docs/widget/CodeViewer.md +130 -0
- package/docs/widget/CollapsibleSideBar.md +112 -0
- package/docs/widget/Column.md +129 -0
- package/docs/widget/Container.md +136 -0
- package/docs/widget/DataTable.md +150 -0
- package/docs/widget/Divider.md +109 -0
- package/docs/widget/DraggBox.md +129 -0
- package/docs/widget/Drawer.md +135 -0
- package/docs/widget/DrawerItem.md +98 -0
- package/docs/widget/Dropdown.md +139 -0
- package/docs/widget/DroppBox.md +152 -0
- package/docs/widget/FloatingActionButton.md +120 -0
- package/docs/widget/GridView.md +140 -0
- package/docs/widget/Icon.md +117 -0
- package/docs/widget/Image.md +125 -0
- package/docs/widget/Input.md +151 -0
- package/docs/widget/Inspector.md +92 -0
- package/docs/widget/InstallButton.md +128 -0
- package/docs/widget/ListTile.md +132 -0
- package/docs/widget/ListView.md +138 -0
- package/docs/widget/Markdown.md +175 -0
- package/docs/widget/MatrixRain.md +122 -0
- package/docs/widget/Modal.md +129 -0
- package/docs/widget/Pagination.md +135 -0
- package/docs/widget/ParallaxBox.md +128 -0
- package/docs/widget/ProgressBar.md +130 -0
- package/docs/widget/QRCode.md +117 -0
- package/docs/widget/README.md +188 -0
- package/docs/widget/Radio.md +123 -0
- package/docs/widget/Rating.md +131 -0
- package/docs/widget/Row.md +131 -0
- package/docs/widget/START_HERE.md +146 -0
- package/docs/widget/Scaffold.md +152 -0
- package/docs/widget/Skeleton.md +130 -0
- package/docs/widget/Slider.md +146 -0
- package/docs/widget/SnackBar.md +102 -0
- package/docs/widget/Stack.md +128 -0
- package/docs/widget/Stepper.md +145 -0
- package/docs/widget/Switch.md +118 -0
- package/docs/widget/Tabs.md +124 -0
- package/docs/widget/Text.md +133 -0
- package/docs/widget/Tooltip.md +145 -0
- package/docs/widget/TreeView.md +176 -0
- package/docs/widget/Video.md +127 -0
- package/docs/widget/_template.md +61 -0
- package/package.json +4 -2
- package/src/animations/AnimatedBox.js +32 -1
- package/src/animations/AnimatedText.js +7 -3
- package/src/animations/MatrixRain.js +37 -12
- package/src/animations/ParallaxBox.js +16 -3
- package/src/animations/animate.js +187 -58
- package/src/animations/index.js +1 -0
- package/src/core/runApp.js +13 -1
- package/src/create-index.sh +1 -1
- package/src/index.d.ts +227 -91
- package/src/index.js +1 -0
- package/src/navigations/AdaptiveScaffold.js +11 -2
- package/src/navigations/AppBar.js +8 -2
- package/src/navigations/BottomNavigation.js +24 -5
- package/src/navigations/DrawerItem.js +16 -3
- package/src/navigations/Scaffold.js +8 -1
- package/src/navigations/Tabs.js +40 -8
- package/src/tools/dimensions.js +11 -3
- package/src/tools/useState.js +139 -101
- package/src/utils/getWidgetProps.js +5 -3
- package/src/widget-factory/assignProps.js +30 -11
- package/src/widget-factory/processProps.js +17 -5
- package/src/widget-factory/reactiveValue.js +172 -0
- package/src/widget-factory/translateProps.js +777 -901
- package/src/widget-factory/warnings.js +15 -0
- package/src/widget-factory/widgetFactory.js +27 -0
- package/src/widgets/Accordion.js +6 -5
- package/src/widgets/AlertDialog.js +7 -5
- package/src/widgets/Audio.js +30 -8
- package/src/widgets/BottomSheet.js +24 -1
- package/src/widgets/Chart.js +4 -1
- package/src/widgets/Checkbox.js +16 -8
- package/src/widgets/CircularBar.js +12 -1
- package/src/widgets/CircularChart.js +4 -1
- package/src/widgets/CodeViewer.js +26 -8
- package/src/widgets/DataTable.js +11 -2
- package/src/widgets/Dropdown.js +5 -1
- package/src/widgets/FloatingActionButton.js +4 -7
- package/src/widgets/Image.js +7 -2
- package/src/widgets/Input.js +119 -6
- package/src/widgets/Inspector.js +16 -10
- package/src/widgets/ListView.js +80 -30
- package/src/widgets/Markdown.js +53 -8
- package/src/widgets/Modal.js +24 -1
- package/src/widgets/Pagination.js +6 -3
- package/src/widgets/ProgressBar.js +16 -13
- package/src/widgets/QRCode.js +9 -2
- package/src/widgets/Radio.js +11 -8
- package/src/widgets/Slider.js +26 -4
- package/src/widgets/SnackBar.js +20 -2
- package/src/widgets/Stack.js +36 -3
- package/src/widgets/Stepper.js +4 -3
- package/src/widgets/Switch.js +8 -5
- package/src/widgets/TreeView.js +3 -2
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Common props
|
|
2
|
+
|
|
3
|
+
Every FletBox widget — `Text`, `Container`, `Button`, and all the rest — accepts
|
|
4
|
+
the shared props below in addition to its own widget-specific props. They are
|
|
5
|
+
defined once in the framework's central prop database
|
|
6
|
+
([src/widget-factory/translateProps.js](../../src/widget-factory/translateProps.js)),
|
|
7
|
+
so they behave identically everywhere.
|
|
8
|
+
|
|
9
|
+
Widget pages link here instead of repeating this table. Read this page once and
|
|
10
|
+
you will recognize these props on every widget.
|
|
11
|
+
|
|
12
|
+
## Values and units
|
|
13
|
+
|
|
14
|
+
- **Numbers are pixels.** A numeric value such as `padding: 20` renders as `20px`.
|
|
15
|
+
Internally FletBox converts it to `rem` on a 16px base (`20 / 16 = 1.25rem`), so
|
|
16
|
+
spacing and sizes scale if you change the root font size. The exception is
|
|
17
|
+
`borderWidth`, which is applied as raw pixels.
|
|
18
|
+
- **Strings pass through.** A string such as `width: "50%"`, `margin: "8px auto"`,
|
|
19
|
+
or `padding: "10px 18px"` is used as-is, so any valid CSS value works.
|
|
20
|
+
- **Unitless props** (`opacity`, `zIndex`, `weight`, colors, `flex`, …) take their
|
|
21
|
+
value directly with no unit appended.
|
|
22
|
+
|
|
23
|
+
## Aliases (multi-dialect props)
|
|
24
|
+
|
|
25
|
+
FletBox intentionally accepts several spellings for the same thing, so developers
|
|
26
|
+
coming from Flet, Flutter, React, or vanilla JavaScript can write what feels
|
|
27
|
+
natural. Each group below maps to the same underlying style or behavior:
|
|
28
|
+
|
|
29
|
+
| Canonical | Aliases | Applies to |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| `width` | `w` | CSS `width` |
|
|
32
|
+
| `height` | `h` | CSS `height` |
|
|
33
|
+
| `minWidth` / `maxWidth` | `minW` / `maxW` | CSS min/max width |
|
|
34
|
+
| `minHeight` / `maxHeight` | `minH` / `maxH` | CSS min/max height |
|
|
35
|
+
| `padding` | `p` | CSS `padding` |
|
|
36
|
+
| `margin` | `m` | CSS `margin` |
|
|
37
|
+
| `paddingTop/Right/Bottom/Left` | `pt` / `pr` / `pb` / `pl` | per-side padding |
|
|
38
|
+
| `marginTop/Right/Bottom/Left` | `mt` / `mr` / `mb` / `ml` | per-side margin |
|
|
39
|
+
| `backgroundColor` | `bgColor`, `bg` | CSS `background-color` |
|
|
40
|
+
| `color` | `textColor` | CSS `color` (foreground/text) |
|
|
41
|
+
| `fontSize` | `size` | CSS `font-size` |
|
|
42
|
+
| `fontWeight` | `weight` | CSS `font-weight` |
|
|
43
|
+
| `borderRadius` | `rounded` | CSS `border-radius` |
|
|
44
|
+
| `boxShadow` | `shadow` | CSS `box-shadow` |
|
|
45
|
+
| `position` | `pos` | CSS `position` |
|
|
46
|
+
| `zIndex` | `z` | CSS `z-index` |
|
|
47
|
+
| `flexDirection` | `direction` | CSS `flex-direction` |
|
|
48
|
+
| `justifyContent` | `justify` | CSS `justify-content` |
|
|
49
|
+
| `alignItems` | `align` | CSS `align-items` |
|
|
50
|
+
| `flexWrap` | `wrap` | CSS `flex-wrap` |
|
|
51
|
+
| `lineHeight` | `lineH` | CSS `line-height` |
|
|
52
|
+
| `letterSpacing` | `letterSpace` | CSS `letter-spacing` |
|
|
53
|
+
| `onClick` | `onPress`, `onclick` | click handler |
|
|
54
|
+
|
|
55
|
+
> Note: some widgets reuse a common name for a widget-specific meaning. For
|
|
56
|
+
> example, in [`Text`](Text.md) the `align` prop sets **text alignment**
|
|
57
|
+
> (`textAlign`), while in layout widgets like [`Row`](Row.md) and
|
|
58
|
+
> [`Column`](Column.md) `align` sets **`alignItems`**. Always check the widget
|
|
59
|
+
> page for its own props.
|
|
60
|
+
|
|
61
|
+
## Shorthand spacing
|
|
62
|
+
|
|
63
|
+
These expand to two sides at once (numeric values are pixels):
|
|
64
|
+
|
|
65
|
+
- `px` / `paddingHorizontal` → left + right padding
|
|
66
|
+
- `py` / `paddingVertical` → top + bottom padding
|
|
67
|
+
- `mx` / `marginHorizontal` → left + right margin
|
|
68
|
+
- `my` / `marginVertical` → top + bottom margin
|
|
69
|
+
|
|
70
|
+
## Layout and display
|
|
71
|
+
|
|
72
|
+
`display`, `flexDirection` (`direction`), `justifyContent` (`justify`),
|
|
73
|
+
`alignItems` (`align`), `flexWrap` (`wrap`), `flex`, `flexGrow`, `flexShrink`,
|
|
74
|
+
`flexBasis`, `gap`, `boxSizing`, `overflow`, `overflowX`, `overflowY`,
|
|
75
|
+
`position` (`pos`), `top`, `right`, `bottom`, `left`, `inset`, `zIndex` (`z`).
|
|
76
|
+
|
|
77
|
+
## Size and spacing
|
|
78
|
+
|
|
79
|
+
`width` (`w`), `height` (`h`), `minWidth`/`maxWidth`, `minHeight`/`maxHeight`,
|
|
80
|
+
`padding` (`p`) and per-side variants, `margin` (`m`) and per-side variants,
|
|
81
|
+
`gap`, and the horizontal/vertical shorthands above.
|
|
82
|
+
|
|
83
|
+
## Color and background
|
|
84
|
+
|
|
85
|
+
`backgroundColor` (`bgColor`, `bg`), `color` (`textColor`), `opacity`,
|
|
86
|
+
`gradient` (CSS `background`), `bgImage`, `bgSize`, `bgPosition`, `bgRepeat`.
|
|
87
|
+
|
|
88
|
+
## Typography
|
|
89
|
+
|
|
90
|
+
`fontSize` (`size`), `fontWeight` (`weight`), `fontFamily`, `textAlign`,
|
|
91
|
+
`lineHeight` (`lineH`), `letterSpacing` (`letterSpace`), `textDecoration`,
|
|
92
|
+
`textTransform`, `whiteSpace`, `wordBreak`, `textOverflow`.
|
|
93
|
+
|
|
94
|
+
## Border, radius and shadow
|
|
95
|
+
|
|
96
|
+
`border`, `borderColor`, `borderWidth`, `borderStyle`, `borderTop`, `borderRight`,
|
|
97
|
+
`borderBottom`, `borderLeft`, `borderRadius` (`rounded`), and the corner
|
|
98
|
+
shorthands `roundedTop`, `roundedBottom`, `roundedLeft`, `roundedRight`, plus
|
|
99
|
+
`boxShadow` (`shadow`) and `elevation`.
|
|
100
|
+
|
|
101
|
+
> `elevation` is widget-specific on some components (for example
|
|
102
|
+
> [`Button`](Button.md) maps `0`–`5` to preset shadows). As a common style prop it
|
|
103
|
+
> is treated as a `box-shadow` value.
|
|
104
|
+
|
|
105
|
+
## Animation and transform
|
|
106
|
+
|
|
107
|
+
`transition`, `animation`, `transform`, `cursor`, `visibility`, `pointerEvents`,
|
|
108
|
+
`userSelect`, `touchAction`.
|
|
109
|
+
|
|
110
|
+
## Text content
|
|
111
|
+
|
|
112
|
+
These set the element's text: `text`, `label`, `title`, `caption`, `description`,
|
|
113
|
+
`message`, `buttonText`, and `textContent`.
|
|
114
|
+
|
|
115
|
+
## HTML attributes
|
|
116
|
+
|
|
117
|
+
`id`, `className` (`class`), `name`, `type`, `href`, `src`, `alt`, `disabled`,
|
|
118
|
+
`readOnly`, `required`, `checked`, `selected`, `placeholder`, `min`, `max`,
|
|
119
|
+
`step`, `pattern`, `role`, `lang`, `dir`, `tabIndex`, `draggable`, `hidden`,
|
|
120
|
+
`for` (`htmlFor`), `autofocus`, `autocomplete`, `spellcheck`. Any `data-*` or
|
|
121
|
+
`aria-*` attribute is also passed through.
|
|
122
|
+
|
|
123
|
+
## Events
|
|
124
|
+
|
|
125
|
+
`onClick` (`onPress`, `onclick`), `onDoublePress`, `onRightClick`, `onHover`,
|
|
126
|
+
`onHoverEnd`, `onFocus`, `onBlur`, `onChange`, `onInput`, `onScroll`, `onKeyDown`,
|
|
127
|
+
`onKeyUp`, `onKeyPress`, `onMouseDown`, `onMouseUp`, `onMouseMove`,
|
|
128
|
+
`onTouchStart`, `onTouchMove`, `onTouchEnd`. Any other `on<Event>` prop with a
|
|
129
|
+
function value is attached as a native listener.
|
|
130
|
+
|
|
131
|
+
## Structure and refs
|
|
132
|
+
|
|
133
|
+
- `child`: a single child widget.
|
|
134
|
+
- `children`: an array of child widgets.
|
|
135
|
+
- `ref`: a callback that receives the underlying DOM node — `ref: (el) => (myRef = el)`.
|
|
136
|
+
|
|
137
|
+
> There is intentionally **no `style` prop**. FletBox uses flat, aliased CSS
|
|
138
|
+
> props instead. Passing `style: { ... }` is rejected with a console warning;
|
|
139
|
+
> write the same declarations flat (`backgroundColor`, `padding`, `flexDirection`, …).
|
|
140
|
+
|
|
141
|
+
## Reactivity
|
|
142
|
+
|
|
143
|
+
Most style, spacing, color, typography, and text props are **reactive**: when they
|
|
144
|
+
are bound to state via [`useState`](../guides/state.md), the widget updates in
|
|
145
|
+
place when the value changes, without a full re-render.
|
|
146
|
+
|
|
147
|
+
## Related
|
|
148
|
+
|
|
149
|
+
- [Syntax philosophy](../guides/syntax-philosophy.md) — why aliases coexist.
|
|
150
|
+
- [Widget index](README.md) — the full book of widgets.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A rounded, optionally elevated surface that groups related content into a single tappable unit.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it to present a self-contained block such as a summary, product, or stat.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Card, Text } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const card = Card({
|
|
15
|
+
child: Text({ text: "Hello" }),
|
|
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
|
+
| `child` | `Widget` | A single child widget. Alias: `children` for a list. |
|
|
26
|
+
| `children` | `Widget[]` | An array of child widgets. Alias: `child` for a single child. |
|
|
27
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
28
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
29
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
30
|
+
| `showBorder` | `boolean` | Controls whether the border is shown. |
|
|
31
|
+
| `borderWidth` | `number` | Width of the border. |
|
|
32
|
+
| `borderStyle` | `'solid' \| 'dashed' \| 'dotted'` | The `borderStyle` value for the widget. |
|
|
33
|
+
| `borderColor` | `Color` | Color used for the border. |
|
|
34
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
35
|
+
|
|
36
|
+
### Common props
|
|
37
|
+
|
|
38
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
43
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
44
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
45
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
46
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
47
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
48
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
49
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
50
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
51
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
52
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
53
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
54
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
55
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
56
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
57
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
58
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
59
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
60
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
### Everyday
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
import { Card, Text } from "flet-box";
|
|
68
|
+
|
|
69
|
+
const card = Card({
|
|
70
|
+
elevation: 2,
|
|
71
|
+
padding: 16,
|
|
72
|
+
borderRadius: 12,
|
|
73
|
+
child: Text({ text: "Today's summary" }),
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Full
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
import { Card, Text } from "flet-box";
|
|
81
|
+
|
|
82
|
+
const card = Card({
|
|
83
|
+
elevation: 3,
|
|
84
|
+
padding: 20,
|
|
85
|
+
borderRadius: 16,
|
|
86
|
+
showBorder: true,
|
|
87
|
+
borderColor: "#e2e8f0",
|
|
88
|
+
borderWidth: 1,
|
|
89
|
+
onPress: () => console.log("open report"),
|
|
90
|
+
children: [
|
|
91
|
+
Text({ text: "Weekly report", weight: "bold" }),
|
|
92
|
+
Text({ text: "Revenue is up 12% this week." }),
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tips
|
|
98
|
+
|
|
99
|
+
- Keep elevation subtle (1-3) so stacked cards do not look noisy.
|
|
100
|
+
- Set showBorder: true for a flat look, or use elevation for a raised surface.
|
|
101
|
+
|
|
102
|
+
## Accessibility
|
|
103
|
+
|
|
104
|
+
- When onPress is set the whole card becomes a button; make its heading describe the action.
|
|
105
|
+
|
|
106
|
+
## Behavior
|
|
107
|
+
|
|
108
|
+
- Accepts either child for one widget or children for a stacked column of content.
|
|
109
|
+
- onPress fires for clicks anywhere inside the card surface.
|
|
110
|
+
|
|
111
|
+
## Related widgets
|
|
112
|
+
|
|
113
|
+
- [Container](Container.md)
|
|
114
|
+
- [ListTile](ListTile.md)
|
|
115
|
+
- [Button](Button.md)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Continue reading
|
|
120
|
+
|
|
121
|
+
- **Previous:** [Rating](Rating.md)
|
|
122
|
+
- **Next:** [Divider](Divider.md)
|
|
123
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
124
|
+
|
|
125
|
+
You are reading **Chapter 3 · Layout, cards and lists** (1 of 8).
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Carousel
|
|
2
|
+
|
|
3
|
+
Carousel cycles through items one at a time with optional arrows, dots and autoplay. Items may be widgets, image URLs or src/alt objects.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it to showcase a small set of images, banners or promo slides in limited space.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Carousel } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const hero = Carousel({
|
|
15
|
+
items: ["/banner-1.png", "/banner-2.png"],
|
|
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
|
+
| `items` | `(Widget \| string \| { src: string; alt?: string })[]` | Array of items rendered in a rotating or grouped widget. |
|
|
26
|
+
| `autoPlay` | `boolean` | Advances automatically. |
|
|
27
|
+
| `interval` | `number` | Delay between automatic advances, in milliseconds. |
|
|
28
|
+
| `showArrows` | `boolean` | Shows previous/next arrows. |
|
|
29
|
+
| `showDots` | `boolean` | Shows the dot indicators. |
|
|
30
|
+
| `infinite` | `boolean` | Loops from the last item back to the first. |
|
|
31
|
+
| `height` | `number \| string` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
32
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
33
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
34
|
+
| `dotColor` | `Color` | Color used for the dot. |
|
|
35
|
+
| `dotActiveColor` | `Color` | Color used for the dot active. |
|
|
36
|
+
| `dotSize` | `number` | Size of the dot. |
|
|
37
|
+
| `dotActiveSize` | `number` | Size of the dot active. |
|
|
38
|
+
| `buttonBgColor` | `Color` | Background color for the button. |
|
|
39
|
+
| `buttonIconColor` | `Color` | Color used for the button icon. |
|
|
40
|
+
| `buttonSize` | `number` | Size of the button. |
|
|
41
|
+
| `buttonIconSize` | `number` | Size of the button icon. |
|
|
42
|
+
| `buttonTop` | `number \| string` | The `buttonTop` value for the widget. |
|
|
43
|
+
| `onIndexChange` | `(index: number) => void` | Fired with the new active index. |
|
|
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 { Carousel } from "flet-box";
|
|
77
|
+
|
|
78
|
+
const hero = Carousel({
|
|
79
|
+
items: [
|
|
80
|
+
{ src: "/sale.png", alt: "Summer sale" },
|
|
81
|
+
{ src: "/launch.png", alt: "New launch" },
|
|
82
|
+
],
|
|
83
|
+
autoPlay: true,
|
|
84
|
+
interval: 4000,
|
|
85
|
+
showDots: true,
|
|
86
|
+
showArrows: true,
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Full
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
import { Carousel, Text } from "flet-box";
|
|
94
|
+
|
|
95
|
+
const hero = Carousel({
|
|
96
|
+
items: [
|
|
97
|
+
{ src: "/sale.png", alt: "Summer sale" },
|
|
98
|
+
{ src: "/launch.png", alt: "New launch" },
|
|
99
|
+
Text({ text: "Featured story" }),
|
|
100
|
+
],
|
|
101
|
+
autoPlay: true,
|
|
102
|
+
interval: 5000,
|
|
103
|
+
infinite: true,
|
|
104
|
+
showArrows: true,
|
|
105
|
+
showDots: true,
|
|
106
|
+
height: 320,
|
|
107
|
+
width: "100%",
|
|
108
|
+
borderRadius: 16,
|
|
109
|
+
dotColor: "#cbd5e1",
|
|
110
|
+
dotActiveColor: "#2563eb",
|
|
111
|
+
dotSize: 8,
|
|
112
|
+
dotActiveSize: 10,
|
|
113
|
+
buttonBgColor: "#ffffff",
|
|
114
|
+
buttonIconColor: "#0f172a",
|
|
115
|
+
buttonSize: 40,
|
|
116
|
+
buttonIconSize: 20,
|
|
117
|
+
onIndexChange: (index) => console.log(index),
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Tips
|
|
122
|
+
|
|
123
|
+
- Enable autoPlay with a sensible interval and keep showDots on so users can jump to a slide.
|
|
124
|
+
- Mix URL strings, src/alt objects and widgets in items to combine images with captions.
|
|
125
|
+
- Use infinite for looping banners but turn it off when the sequence has a clear first and last slide.
|
|
126
|
+
|
|
127
|
+
## Accessibility
|
|
128
|
+
|
|
129
|
+
- Give image items meaningful alt text so each slide is described.
|
|
130
|
+
- Provide pause and advance controls, and avoid autoplay for content that needs reading time.
|
|
131
|
+
|
|
132
|
+
## Behavior
|
|
133
|
+
|
|
134
|
+
- onIndexChange fires with the new slide index whenever the active item changes.
|
|
135
|
+
- Autoplay is cleared automatically when the widget unmounts.
|
|
136
|
+
|
|
137
|
+
## Related widgets
|
|
138
|
+
|
|
139
|
+
- [Image](Image.md)
|
|
140
|
+
- [Stack](Stack.md)
|
|
141
|
+
- [Card](Card.md)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Continue reading
|
|
146
|
+
|
|
147
|
+
- **Previous:** [TreeView](TreeView.md)
|
|
148
|
+
- **Next:** [InstallButton](InstallButton.md)
|
|
149
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
150
|
+
|
|
151
|
+
You are reading **Chapter 5 · Navigation and flows** (4 of 5).
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Chart
|
|
2
|
+
|
|
3
|
+
Chart draws bar, line, area or candlestick data onto a canvas, with optional labels, grid and value annotations. Numeric arrays drive bar/line/area while OHLC objects drive candle charts.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it to visualize trends and comparisons inline without pulling in a charting library.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Chart } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const totals = Chart({
|
|
15
|
+
type: "bar",
|
|
16
|
+
data: [12, 19, 7, 15],
|
|
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
|
+
| `type` | `'bar' \| 'line' \| 'area' \| 'candle'` | Kind or mode of the widget. |
|
|
27
|
+
| `data` | `number[] \| Array<{ open: number; high: number; low: number; close: number }>` | Array of values or `{ label, value }` slices. |
|
|
28
|
+
| `labels` | `string[]` | Axis or slice labels for the chart. |
|
|
29
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
30
|
+
| `height` | `number` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
31
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
32
|
+
| `padding` | `number \| { top: number; right: number; bottom: number; left: number }` | Space inside the widget, between its content and its border. |
|
|
33
|
+
| `candleWidth` | `number` | Width of each candlestick. |
|
|
34
|
+
| `candleSpacing` | `number` | The `candleSpacing` value for the widget. |
|
|
35
|
+
| `barColor` | `Color` | Color used for the bar. |
|
|
36
|
+
| `lineColor` | `Color` | Color used for the line. |
|
|
37
|
+
| `areaColor` | `Color` | Color used for the area. |
|
|
38
|
+
| `smooth` | `boolean` | Draws a smoothed line instead of straight segments. |
|
|
39
|
+
| `areaGradient` | `boolean` | Fills the area under the line with a gradient. |
|
|
40
|
+
| `areaGradientColors` | `[string, string]` | The `areaGradientColors` value for the widget. |
|
|
41
|
+
| `candleUpColor` | `Color` | Color used for the candle up. |
|
|
42
|
+
| `candleDownColor` | `Color` | Color used for the candle down. |
|
|
43
|
+
| `axisColor` | `Color` | Color used for the axis. |
|
|
44
|
+
| `textColor` | `Color` | Color of the button label. |
|
|
45
|
+
| `yAxisColor` | `Color` | Color used for the y axis. |
|
|
46
|
+
| `showGrid` | `boolean` | Shows the chart grid lines. |
|
|
47
|
+
| `showLabels` | `boolean` | Shows chart labels. |
|
|
48
|
+
| `showValues` | `boolean` | Controls whether the values is shown. |
|
|
49
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
50
|
+
|
|
51
|
+
### Common props
|
|
52
|
+
|
|
53
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Description |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
58
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
59
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
60
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
61
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
62
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
63
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
64
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
65
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
66
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
67
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
68
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
69
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
70
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
71
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
72
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
73
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
74
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
75
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
76
|
+
|
|
77
|
+
## Examples
|
|
78
|
+
|
|
79
|
+
### Everyday
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { Chart } from "flet-box";
|
|
83
|
+
|
|
84
|
+
const revenue = Chart({
|
|
85
|
+
type: "line",
|
|
86
|
+
data: [12, 19, 7, 15, 22],
|
|
87
|
+
labels: ["Jan", "Feb", "Mar", "Apr", "May"],
|
|
88
|
+
height: 260,
|
|
89
|
+
showGrid: true,
|
|
90
|
+
showLabels: true,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Full
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { Chart } from "flet-box";
|
|
98
|
+
|
|
99
|
+
const trend = Chart({
|
|
100
|
+
type: "area",
|
|
101
|
+
data: [8, 14, 10, 21, 18, 26],
|
|
102
|
+
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
103
|
+
width: "100%",
|
|
104
|
+
height: 320,
|
|
105
|
+
smooth: true,
|
|
106
|
+
areaGradient: true,
|
|
107
|
+
areaGradientColors: ["#3b82f6", "#bfdbfe"],
|
|
108
|
+
lineColor: "#2563eb",
|
|
109
|
+
areaColor: "#93c5fd",
|
|
110
|
+
axisColor: "#94a3b8",
|
|
111
|
+
textColor: "#475569",
|
|
112
|
+
showGrid: true,
|
|
113
|
+
showLabels: true,
|
|
114
|
+
showValues: true,
|
|
115
|
+
borderRadius: 12,
|
|
116
|
+
bgColor: "#ffffff",
|
|
117
|
+
padding: 16,
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Tips
|
|
122
|
+
|
|
123
|
+
- Match data to type: pass numbers for bar/line/area and open/high/low/close objects for candle.
|
|
124
|
+
- Provide labels so the x-axis is meaningful to readers.
|
|
125
|
+
- Set an explicit height to reserve space and avoid layout shift while the chart initializes.
|
|
126
|
+
|
|
127
|
+
## Accessibility
|
|
128
|
+
|
|
129
|
+
- Add a text summary or table of the values near the chart since canvas content is not readable by screen readers.
|
|
130
|
+
- Use sufficient contrast between data, axis and background colors.
|
|
131
|
+
|
|
132
|
+
## Behavior
|
|
133
|
+
|
|
134
|
+
- The canvas redraws when data, labels, type or styling props change.
|
|
135
|
+
- Candle charts read open, high, low and close in that order from each data object.
|
|
136
|
+
|
|
137
|
+
## Related widgets
|
|
138
|
+
|
|
139
|
+
- [CircularChart](CircularChart.md)
|
|
140
|
+
- [CircularBar](CircularBar.md)
|
|
141
|
+
- [Card](Card.md)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Continue reading
|
|
146
|
+
|
|
147
|
+
- **Previous:** [DataTable](DataTable.md)
|
|
148
|
+
- **Next:** [CircularChart](CircularChart.md)
|
|
149
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
150
|
+
|
|
151
|
+
You are reading **Chapter 6 · Data, rich content & effects** (2 of 13).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
A square checkbox with a check mark that represents an independent true/false choice.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use Checkbox when several options can be selected at once, or when confirming a single item in a form.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Checkbox } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const terms = Checkbox({
|
|
15
|
+
label: "Accept terms",
|
|
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
|
+
| `checked` | `boolean` | Current checked state. |
|
|
26
|
+
| `onCheck` | `(checked: boolean) => void` | Fired with the new checked state. |
|
|
27
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
28
|
+
| `size` | `number` | Overall size preset or pixel value, depending on the widget. |
|
|
29
|
+
| `activeColor` | `Color` | Color used in the active state. |
|
|
30
|
+
| `label` | `string` | Label or caption shown near the control. |
|
|
31
|
+
|
|
32
|
+
### Common props
|
|
33
|
+
|
|
34
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Description |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
39
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
40
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
41
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
42
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
43
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
44
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
45
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
46
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
47
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
48
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
49
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
50
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
51
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
52
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
53
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
54
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
55
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
56
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
### Everyday
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
import { Checkbox } from "flet-box";
|
|
64
|
+
|
|
65
|
+
const remember = Checkbox({
|
|
66
|
+
checked: true,
|
|
67
|
+
label: "Remember me",
|
|
68
|
+
activeColor: "#2563eb",
|
|
69
|
+
onCheck: (checked) => console.log("remember:", checked),
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Full
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
import { Checkbox } from "flet-box";
|
|
77
|
+
|
|
78
|
+
const updates = Checkbox({
|
|
79
|
+
checked: false,
|
|
80
|
+
label: "Email me product updates",
|
|
81
|
+
size: 24,
|
|
82
|
+
activeColor: "#7c3aed",
|
|
83
|
+
disabled: false,
|
|
84
|
+
onCheck: (checked) => {
|
|
85
|
+
console.log("updates:", checked);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Tips
|
|
91
|
+
|
|
92
|
+
- Use Checkbox inside forms where several options may be true together; use Switch for one immediate on/off setting.
|
|
93
|
+
- onCheck fires with the new boolean, so write it straight into your state.
|
|
94
|
+
|
|
95
|
+
## Accessibility
|
|
96
|
+
|
|
97
|
+
- The check box needs an adjacent visible label; assistive tech cannot infer meaning from the tick glyph alone.
|
|
98
|
+
|
|
99
|
+
## Behavior
|
|
100
|
+
|
|
101
|
+
- Uncontrolled when checked is omitted; the widget tracks its own state and reports changes through onCheck.
|
|
102
|
+
- The returned element exposes setChecked(value) and getChecked() for programmatic control.
|
|
103
|
+
|
|
104
|
+
## Related widgets
|
|
105
|
+
|
|
106
|
+
- [Switch](Switch.md)
|
|
107
|
+
- [Radio](Radio.md)
|
|
108
|
+
- [ListTile](ListTile.md)
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Continue reading
|
|
113
|
+
|
|
114
|
+
- **Previous:** [Input](Input.md)
|
|
115
|
+
- **Next:** [Radio](Radio.md)
|
|
116
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
117
|
+
|
|
118
|
+
You are reading **Chapter 2 · Interaction basics** (3 of 8).
|