-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Checkbox prototype * Add fleshed-out check-box * Update changelog * Commit from GitHub Actions (Forui Presubmit) * Update checkbox example * Fix failing build * Commit from GitHub Actions (Forui Samples Presubmit) --------- Co-authored-by: Pante <[email protected]>
- Loading branch information
Showing
16 changed files
with
621 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { Tabs } from 'nextra/components'; | ||
import { Widget } from "../../components/widget"; | ||
|
||
# Checkbox | ||
A control that allows the user to toggle between checked and not checked. It can also be used in a form. | ||
|
||
On touch devices, it is recommended to use a [switch](/docs/switch) instead in most cases. | ||
|
||
<Tabs items={['Preview', 'Code']}> | ||
<Tabs.Tab> | ||
<Widget name='checkbox' query={{enabled: "true"}}/> | ||
</Tabs.Tab> | ||
<Tabs.Tab> | ||
```dart | ||
FCheckBox(); | ||
``` | ||
</Tabs.Tab> | ||
</Tabs> | ||
|
||
## Usage | ||
|
||
### `FCheckbox(...)` | ||
|
||
```dart | ||
FCheckbox( | ||
enabled: true, | ||
initialValue: true, | ||
); | ||
``` | ||
|
||
## Examples | ||
|
||
### Disabled | ||
|
||
<Tabs items={['Preview', 'Code']}> | ||
<Tabs.Tab> | ||
<Widget name='checkbox' query={{enabled: "false"}}/> | ||
</Tabs.Tab> | ||
<Tabs.Tab> | ||
```dart | ||
FCheckbox( | ||
enabled: false, | ||
); | ||
``` | ||
</Tabs.Tab> | ||
</Tabs> | ||
|
||
### Form | ||
|
||
<Tabs items={['Preview', 'Code']}> | ||
<Tabs.Tab> | ||
<Widget name='checkbox' variant='form' query={{enabled: "true"}}/> | ||
</Tabs.Tab> | ||
<Tabs.Tab> | ||
```dart | ||
class LoginForm extends StatefulWidget { | ||
const LoginForm({super.key}); | ||
@override | ||
State<LoginForm> createState() => _LoginFormState(); | ||
} | ||
class _LoginFormState extends State<LoginForm> { | ||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); | ||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
@override | ||
Widget build(BuildContext context) => Form( | ||
key: _formKey, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
FTextField.email( | ||
hint: '[email protected]', | ||
help: const Text(''), | ||
validator: (value) => (value?.contains('@') ?? false) ? null : 'Please enter a valid email.', | ||
), | ||
const SizedBox(height: 4), | ||
FTextField.password( | ||
hint: '', | ||
help: const Text(''), | ||
validator: (value) => 8 <= (value?.length ?? 0) ? null : 'Password must be at least 8 characters long.', | ||
), | ||
const SizedBox(height: 4), | ||
Row( | ||
children: [ | ||
const FCheckbox(), | ||
const SizedBox(width: 7), | ||
Text('Remember password?', style: context.theme.typography.sm), | ||
], | ||
), | ||
const SizedBox(height: 30), | ||
FButton( | ||
label: const Text('Login'), | ||
onPress: () => _formKey.currentState!.validate(), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
``` | ||
</Tabs.Tab> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.