Navigation
Breadcrumbs
The path to the current page, in a <nav aria-label="Breadcrumb">.
JxBreadcrumbs
import 'package:jx_cli/ui.dart'
Available since 0.0.2
Preview
When to use it
- Deep pages of a documentation or a shop.
- Settings sub-pages.
Minimal example
JxBreadcrumbs([
(label: 'Home', href: '/'),
(label: 'Settings', href: null),
])
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
/// Breadcrumbs built from the URL segments.
class PathCrumbs extends StatelessComponent {
const PathCrumbs(this.path, {super.key});
final String path; // '/docs/components/button'
@override
Component build(BuildContext context) {
final parts = path.split('/').where((p) => p.isNotEmpty).toList();
return JxBreadcrumbs([
(label: 'Home', href: '/'),
for (final (i, part) in parts.indexed)
(
label: part[0].toUpperCase() + part.substring(1),
href: i == parts.length - 1 ? null : '/${parts.take(i + 1).join('/')}',
),
]);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
items |
List<JxBreadcrumb> |
required |
Steps, from the root to the current page. |
classes |
String? |
null |
Extra JX classes, appended after the component classes. |
Related types
| Name | Role |
|---|---|
JxBreadcrumb |
Record
({String label, String? href})
. The last step is the current page.
|
Customizing
-
Pass
classesto add or override utilities: they come last, soclasses: 'w:full'wins over the default width.
Responsive
- Steps wrap on narrow screens.
Accessibility
-
A
<nav>landmark named "Breadcrumb" with an ordered list. -
The last step carries
aria-current="page"; separators are hidden from screen readers.