Overlays
Drawer
A panel that slides in from the side of the screen. Same native dialog behavior as the modal.
JxDrawer
import 'package:jx_cli/ui.dart'
New in 0.0.3
Preview
When to use it
- Filters of a list.
- A mobile menu.
- Details of a selected row.
Minimal example
JxModalTrigger(target: 'menu', [.text('Menu')])
JxDrawer(id: 'menu', title: 'Menu', side: JxDrawerSide.left, [ /* links */ ])
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
class FiltersDrawer extends StatelessComponent {
const FiltersDrawer({required this.onApply, super.key});
final VoidCallback onApply;
@override
Component build(BuildContext context) {
return Component.fragment([
const JxModalTrigger(target: 'filters', variant: JxButtonVariant.outline, [.text('Filters')]),
JxDrawer(
id: 'filters',
title: 'Filters',
actions: [
JxButton(onClick: onApply, attributes: JxModal.closeAttributes('filters'), [.text('Apply')]),
],
const [
JxSelect(
id: 'filter-period',
label: 'Period',
options: [(value: '30', label: 'Last 30 days'), (value: '365', label: 'Last year')],
),
JxSwitch(id: 'filter-archived', label: 'Include archived'),
],
),
]);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
children |
List<Component> |
required |
Body of the panel. |
id |
String |
required |
Referenced by
JxModalTrigger.target
.
|
title |
String |
required |
Heading and accessible name. |
description |
String? |
null |
Text under the title. |
actions |
List<Component>? |
null |
Buttons pinned to the bottom of the panel. |
side |
JxDrawerSide |
right |
left
or
right
.
|
dismissible |
bool |
true |
A click on the backdrop closes it. |
closeLabel |
String |
'Close' |
Accessible name of the × button. |
classes |
String? |
null |
Extra JX classes, appended after the component classes. |
Related types
| Name | Role |
|---|---|
JxDrawerSide |
left, right. |
Customizing
-
Pass
classesto add or override utilities: they come last, soclasses: 'w:full'wins over the default width. -
Change the width with
classes: 'w:[min(32rem,100%)]'.
Responsive
- 24rem wide, never wider than the screen: on phones it covers the whole width.
Accessibility
- Same as the modal: focus kept inside, Escape closes, page behind inert, focus returned to the trigger.
- The slide-in is disabled when the system asks for reduced motion.
Limitations
-
Same browser support notes as the modal (command buttons,
closedby). - No closing animation.