You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: libs/design/sidebar/README.md
+58-17
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,53 @@ Sidebar is a component used to display additional information to the side of a p
4
4
## Overview
5
5
Sidebars are often used for navigation, but it's built to be flexible and extensible so that it can be used for any content. Sidebar supports a header and footer component with minimal default styling.
6
6
7
-
### Basic sidebar
7
+
## Usage
8
+
9
+
### Within a standalone component
10
+
To use sidebar in a standalone component, import `DAFF_SIDEBAR_COMPONENTS` directly into your custom component:
11
+
12
+
```ts
13
+
@Component({
14
+
selector: 'custom-component',
15
+
templateUrl: './custom-component.component.html',
16
+
standalone: true,
17
+
imports: [
18
+
DAFF_SIDEBAR_COMPONENTS,
19
+
],
20
+
})
21
+
exportclassCustomComponent {}
22
+
```
23
+
24
+
### Within a module (deprecated)
25
+
To use sidebar in a module, import `DaffSidebarModule` into your custom module:
The main and sidebar content should be placed inside of the `<daff-sidebar-viewport>`. The sidebar content should be placed inside of the `<daff-sidebar>`.
14
55
15
56
A viewport navigation can either be:
@@ -50,17 +91,17 @@ A viewport navigation can either be:
50
91
</daff-sidebar-viewport>
51
92
```
52
93
53
-
####Required Imports
94
+
### Required Imports
54
95
The `BrowserAnimationsModule` or `NoopAnimationsModule` must be imported in the particular Angular `@NgModule` the sidebar is used in for the sidebar to render and work properly.
55
96
56
-
###Header and footer
97
+
## Header and footer
57
98
The `<daff-sidebar-header>` includes optional title (`[daffSidebarHeaderTitle]`) and action (`[daffSidebarHeaderAction]`) selectors, and a slot to render custom content. The action selector should be used along with the `<daff-icon-button>` (view [Button Documentation](/libs/design/button/README.md)) to make sure that the action is positioned correctly and it passes WCAG guidelines.
58
99
59
100
The `<daff-sidebar-footer>` is a "holder" component with minimal default styling. Its main purpose is to position the footer at the bottom of the sidebar, allowing the sidebar's content to overflow and scroll while ensuring that the footer remains constantly visible.
60
101
61
102
Both the header and footer are optional components that will not render in the DOM if they are not used.
62
103
63
-
###Opening and closing a sidebar
104
+
## Opening and closing a sidebar
64
105
THe `open` property is used to set the open state for a sidebar.
65
106
66
107
By default, sidebar supports two methods of closing itself: clicking on the backdrop of the sidebar viewport or pressing `ESC` when the sidebar has focus.
@@ -69,7 +110,7 @@ By default, sidebar supports two methods of closing itself: clicking on the back
69
110
|`(backdropClicked)`| Set on the `<daff-sidebar-viewport>`|
70
111
|`(escapePressed)`| Set on the `<daff-sidebar>`|
71
112
72
-
###Modes
113
+
## Modes
73
114
`<daff-sidebar>` can be rendered four different ways by using the `mode` property. If `mode` is not specified, `side` is used by default.
74
115
75
116
| Mode | Description |
@@ -79,27 +120,27 @@ By default, sidebar supports two methods of closing itself: clicking on the back
79
120
| over | Sidebar slides over the rest of the content in the viewport and covering it with a backdrop |
80
121
| under | Sidebar freezes in place and and the content slides above it, while also being covered by a backdrop |
| left | Places sidebar on the left side of the screen |
100
141
| right | Places sidebar on the right side of the screen |
101
142
102
-
###Custom styles
143
+
## Custom styles
103
144
104
145
#### Setting a sidebar's width
105
146
The default size of a sidebar is `240px`. The `--daff-sidebar-left-width` and `--daff-sidebar-right-width` variables can be used to change the width of a left or right sidebar. These variables need to be defined on `<daff-sidebar-viewport>` or on the shadow DOM.
@@ -127,7 +168,7 @@ daff-sidebar-viewport {
127
168
}
128
169
```
129
170
130
-
###Changing a side-fixed sidebar's top offset position
171
+
## Changing a side-fixed sidebar's top offset position
131
172
The default offset position of a sidebar is `0px`. The `--daff-sidebar-side-fixed-top-shift` variable can be used to adjust the top offset position for a primary sidebar and its viewport content.
A meaningful `role` should be set on all sidebars depending on how they are used.
148
189
149
190
When the `<daff-sidebar-header>` is not used or there is no title for the sidebar, a meaningful `aria-label` should be set to describe the sidebar.
150
191
151
-
####Focus
192
+
### Focus
152
193
Focus trapping is enabled for `over` and `under` modes, and disabled for `side` and `side-fixed` modes. When a sidebar is opened, the first tabbable element within the will receive focus. When a sidebar is opened, the first tabbable element within the will receive focus. When a sidebar is closed, the element that was focused before the sidebar was opened will be re-focused.
0 commit comments